ผู้เขียน/โดย : เกริก ภิรมย์โสภา (Krerk Piromsopa)
เขียนเมื่อ/ปรับปรุง : 2004-07-12 14:50:46
Thank you to “Kika Barokas” for Card format [MS Word].
DML (Data Manipulation Language)
SELECT [DISTINCT | DISTINCTROW | ALL]
select_expression,…
[FROM table_references
[WHERE where_definition]
[GROUP BY col_name,...]
[HAVING where_definition]
[ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,…]
[LIMIT [offset,] rows]
[PROCEDURE procedure_name] ]
table_reference, table_reference
table_reference [CROSS] JOIN table_reference
table_reference INNER JOIN table_reference
table_reference STRAIGHT_JOIN table_reference
table_reference LEFT [OUTER] JOIN table_reference ON conditional_expr
table_reference LEFT [OUTER] JOIN table_reference USING (column_list)
table_reference NATURAL LEFT [OUTER] JOIN table_reference
INSERT [INTO] tbl_name [(col_name,...)]
VALUES (expression,…),(…),…
INSERT [INTO] tbl_name [(col_name,...)]
SELECT …
INSERT [INTO] tbl_name
SET col_name=expression, col_name=expression, …
DELETE [LOW_PRIORITY] FROM tbl_name
[WHERE where_definition]
UPDATE tbl_name SET col_name1=expr1,col_name2=expr2,…
[WHERE where_definition]
DDL (Data Definition Language)
CREATE TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options] [select_statement]
create_definition: col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [PRIMARY KEY] [reference_definition]
or PRIMARY KEY (index_col_name,…)
or KEY [index_name] (index_col_name,…)
or INDEX [index_name] (index_col_name,…)
or UNIQUE [INDEX] [index_name] (index_col_name,…)
or [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,…) [reference_definition]
or CHECK (expr)
DROP TABLE [IF EXISTS] tbl_name [, tbl_name,...]
ALTER TABLE tbl_name alter_spec [, alter_spec ...]
alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
or ADD [COLUMN] (create_definition, create_definition,…)
or ADD INDEX [index_name] (index_col_name,…)
or ADD PRIMARY KEY (index_col_name,…)
or ADD UNIQUE [index_name] (index_col_name,…)
or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
or CHANGE [COLUMN] old_col_name create_definition
or MODIFY [COLUMN] create_definition
or DROP [COLUMN] col_name
or DROP PRIMARY KEY
or DROP INDEX index_name
or RENAME [AS] new_tbl_name
or table_options
CREATE [UNIQUE] INDEX index_name ON tbl_name (col_name[(length)],… )
DROP INDEX index_name ON tbl_name
CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|REAL|INTEGER}
SONAME shared_library_name
DROP FUNCTION function_name
AC (Access Control)
GRANT priv_type [(column_list)] [, priv_type [(column_list)] …]
ON {tbl_name | * | *.* | db_name.*}
TO user_name [IDENTIFIED BY 'password']
[, user_name [IDENTIFIED BY 'password'] …]
[WITH GRANT OPTION]
REVOKE priv_type [(column_list)] [, priv_type [(column_list)] …]
ON {tbl_name | * | *.* | db_name.*}
FROM user_name [, user_name ...]
priv_type:
| ALL PRIVILEGES | FILE | RELOAD | ALTER | INDEX |
| SELECT | CREATE | INSERT | SHUTDOWN | DELETE |
| PROCESS | UPDATE | DROP | REFERENCES | USAGE |
TC (Transaction Control)
COMMIT [WORK]
ROLLBACK [WORK]
Programmatic SQL
EXPLAIN tbl_name
EXPLAIN SELECT select_options
{DESCRIBE | DESC} tbl_name {col_name | wild}
Computer Architecture