Common MySQL Statements
Short reference to some useful MySQL statements to create and update table structures (metadata) and do
some common queries, updates and deletions from tables.
Domain
Creating a domainCREATE DOMAIN AS <domain_name> AS CHAR(5);
Managing Table Structure
Creating tablesCREATE TABLE <table_name> ( <attribute_name> <attribute_type> <”” | PRIMARY KEY | NOT NULL > );Deleting tablesDROP TABLE <table_name>;Deleting columnsALTER TABLE <table_name> DROP <column_name>Adding columnsALTER TABLE <table_name> ADD <attribute_name> <attribute_type> <conditions> ;
Managing data
Deleting rowsDELETE FROM <table_name> ; *Deletes all rows from the table DELETE FROM <table_name> WHERE <attribute_name> <condition> <value> ; *Deletes rows that match conditionInserting rowsINSERT INTO <table_name> ( <attributeAname>, ... , <attributeName> ) VALUES ( '<attributeA_value>', .... , '<attributeZ_value>' );Updating RowsUPDATE <table_name> SET <attribute_name> = <value> WHERE <attribute_name> <condition> <value> ;Searching Rows (basic)SELECT < * | <attribute_list > ROM <table_name> WHERE <search_condition> [ ORDER BY <attribute> ];