Cheatography
https://cheatography.com
Basic commands, for MYSQL
This is a draft cheat sheet. It is a work in progress and is not finished yet.
CREATE, DROP, DESCRIBE
CREATE DATABASE nameDataBase; |
DROP DATABASE nameDataBase; |
DESCRIBE nameDataBase; |
CREATE and DROP TABLES
CREATE TABLE nameTable; |
DROP TABLE nameTable |
ADD COLUMN ON TABLE
ALTER TABLE table1 ADD newColum varchar(20) NOT NULL |
ALTER TABLE table1 ADD newColum INT AFTER colum1; |
ALTER TABLE table1 ADD newColumn INT FIRST; |
ALTER and MODIFY TABLES
ALTER TABLE table1 MODIFY colum2 INT; |
ALTER TABLE table1 MODIFY colum1 varchar(10) AFTER colum0; |
ALTER TABLE table1 MODIFY column1 varchar(10) NOT NULL FIRST; |
DROP COLUMN ON TABLES
ALTER TABLE table1 DROP nameColumn; |
ALTER TABLE table1 DROP COLUMN nameColumn; |
CHANGE NAME COLUMN
ALTER TABLE table1 CHANGE COLUMN oldName newName varchar(20) NOT NULL; |
ALTER TABLE table1 CHANGE COLUMN oldName newName varchar(10) NOT NULL FIST; |
ALTER TABLE table1 CHANGE COLUMN oldName newName varchar(10) NOT NULL AFTER nameColum |
|
|
RENAME TABLE
ALTER TABLE table1 RENAME TO newNameTable |
|
|
|
|
|