Show Menu
Cheatography

Basic MYSQL Cheat Sheet (DRAFT) by

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 nameDa­taBase;
DROP DATABASE nameDa­taBase;
DESCRIBE nameDa­taBase;

CREATE and DROP TABLES

CREATE TABLE nameTable;
DROP TABLE nameTable

ADD COLUMN ON TABLE

ALTER TABLE table1 ADD newColum varcha­r(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 varcha­r(10) AFTER colum0;
ALTER TABLE table1 MODIFY column1 varcha­r(10) NOT NULL FIRST;

DROP COLUMN ON TABLES

ALTER TABLE table1 DROP nameCo­lumn;
ALTER TABLE table1 DROP COLUMN nameCo­lumn;

CHANGE NAME COLUMN

ALTER TABLE table1 CHANGE COLUMN oldName newName varcha­r(20) NOT NULL;
ALTER TABLE table1 CHANGE COLUMN oldName newName varcha­r(10) NOT NULL FIST;
ALTER TABLE table1 CHANGE COLUMN oldName newName varcha­r(10) NOT NULL AFTER nameColum
 

RENAME TABLE

ALTER TABLE table1 RENAME TO newNam­eTable