0% found this document useful (0 votes)
2 views2 pages

MySQL Queries

The document outlines a series of SQL commands for managing databases, tables, and user permissions. It includes commands for creating, altering, and dropping databases and tables, as well as inserting, updating, and selecting data. Additionally, it covers user management and permissions within a database context.

Uploaded by

Helping Hand
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
2 views2 pages

MySQL Queries

The document outlines a series of SQL commands for managing databases, tables, and user permissions. It includes commands for creating, altering, and dropping databases and tables, as well as inserting, updating, and selecting data. Additionally, it covers user management and permissions within a database context.

Uploaded by

Helping Hand
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

I.

show databases;
II. create database <database name> ;
III. desc <database name> ;
IV. insert into <database values> values ();
V. select <column name> from <table name> where column name > condition;
VI. select * from <table name> where <condition> IN (10000 , 50000) ;
VII. alter table <table name> rename column <previous column name> to <new column name>;
VIII. alter table <table name> modify column <column name > <range>;
IX. alter table <table name> add column <column name> <data type>;
X. alter table <table name> drop column <column name>;
XI. drop table <table name>;
XII. drop database <database name>;
XIII. update <table name> set <column name>= "values" where condition = value;
XIV. select * from <table name> where <column name> IS NULL;
XV. select * from <table name> where <column name> IS NOT NULL;
XVI. select * from <table name> where <column name> LIKE "%r";
XVII. select * from <table name> order by <column name> desc;
XVIII. select * from <table name> order by <column name> asc ;
XIX. select min(<column name>) as <alias name> from <table name>;
XX. select max(<column name>)as <alias name> from <table name>;
XXI. select avg(salary) as <alias name> from <table name>;
XXII. select sum(salary) as <alias name> from <table name>;
XXIII. select count(*) as <alias name> from <table name>;
XXIV. select <column_name1> from <table_name1> UNION select <column_name2> from
<table_name2>;
XXV. select <column_name1> from <table_name1>INTERSECT select <column_name2> from
<table_name2>;
XXVI. select <column name> from <table name> where condition > (select aggregate
function(<column name>) from <table name>);
XXVII. select <t1>.<column_name1> , <t2>.<column_name2> FROM <t1> JOIN <t2> ON t1.<same
column name> = t2.<same column name>;
XXVIII. create view <view name> as select <column name> from <table name> ;
XXIX. select * from <view name> ;
XXX. alter view <view name> as select <column name> from <table name> ;
XXXI. drop view if exists <view name>;
XXXII. create index <index name> ON <table_name1>(<column_name1) ;
XXXIII. show index from <index name> ;
XXXIV. drop index <index name> on <table name>;
XXXV. select <column name> from <table name> where condition > value and <condition_id>
between 1 and 3;
XXXVI. create database <example database>
XXXVII. create table users (id int auto increment primary key, username varchar(50), password
varchar(50) );
XXXVIII. create user <'app user'@'localhost'> identified by 'password';
XXXIX. grant select, insert, update, delete on <example db.users> to 'app_user'@'localhost';
XL. revoke update on example_db.users from 'app_user'@'localhost';
XLI. show grants for 'app_user'@'localhost';

You might also like