




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





MYSQL DDL - create , alter , drop , truncate DML - select , insert , delete , update DCL - grant , revoke TCL - commit , rollback , savepoint COMMAND STRUCTURE SELECT FROM WHERE GROUP BY HAVING ORDER BY DATA TYPES
Show databases; Use database_name; Show tables; Desc table_name; / describe table_name; Select * from table_name; Create database database_name; Create table table_name (col1 datatype primary key not null,....,col datatype,...);
Select * from table_name where age in (20,30,40); Select * from table_name where age between 30 and 60; Group By Groups the rows that have same value into summary rows , often used with aggregate functions Select count(id) , gender from employee group by gender; Output : count(id) gender 2 M 4 F Order By Select * from table_name order by col_name; → asc by default Select * from table_name order by col_name desc; Select Select (10+20) as add; output : add 30 Select length (‘Phooja’) as length; string measured in bytes. Select character_length (‘Phooja’) as length; string measured in characters.
output: length 6 Select repeat (num/char/string/col_name , no of times); select repeat('a',13); Output : aaaaaaaaaaaaa Select upper (col_name) from table_name; →convert to upper case; Select lower (col_name) from table_name ; → convert to lowercase; Select upper (‘india’) from table_name ; Select lower (INDIA) from table_name ; Select curdate (); →return current date; Select day (curdate()); →return which day i.e 28,12,etc.. Select now (); →return current date and time; Drop Drop table table_name; → delete the entire table Truncate Truncate table table_name; → deletes all the records in the table bu the structure remains the same;
● YEAR - format YYYY or YY Select year (doj); extract year DROP Alter table table_name drop primary key ; Alter table table_name drop foreign key col_name; Alter table table_name drop check col_name;