MySQL Quick List of Useful Command Syntax

Databases

SHOW DATABASES;
SHOW TABLES;
SHOW TABLES FROM db-name;
SHOW COLUMNS from tbl_name;
SHOW INDEX from tbl_name;

Tables

Create TABLE tbl_name;
ALTER TABLE tbl_name RENAME as new_tbl_name;
ALTER TABLE tbl_name CHANGE old_col new_col newtype;
ALTER TABLE tbl_name MODIFY variable newtype;
ALTER TABLE tbl_name ADD variable type;
ALTER TABLE tbl_name drop col_name;
DROP TABLE tbl_name;
DESCRIBE tbl_name;

Rows

INSERT INTO tbl_name (variable1, variable2) VALUES(value1, value2);
INSERT INTO tbl_name SET variable1=value, variable2 =value2;
DELETE FROM tbl_name WHERE expression;
UPDATE tbl_name SET col_name1=expr, col_name2=expr;


© Copyright Pixelloom, LLC 2006. All Rights Reserved.