SQL命令按照上图分为四类,DDL,DML,DCL,TCL
DDL (Data Definition Language) :
DDL用于定义 数据库的结构或schema,DDL也用于指定数据额外的属性。
数据存入数据库必须满足特定的一致性约束 consistency constraints
比如,假设大学要求账户余额不能为负数,DDL提供这种能力来指定这种约束。
数据库会在每次数据更新的时候来检查这些约束。
命令包括
CREATE : to create objects in database
ALTER : alters the structure of database
DROP : delete objects from database
RENAME : rename an objects
DML (Data Manipulation Language) :
DML语句又分为两类
声明式(Declarative DMLs)和过程式(Procedural DMLs)
过程式DML 需要指定获取哪些数据 以及如何获取
声明式DML只需要指定要获取哪些数据,不用管如何获取。
命令包括
SELECT: retrieve data from the database
INSERT: insert data into a table
UPDATE: update existing data within a table
DELETE: deletes all records from a table, space for the records remain
TCL (Transaction Control Language) :
事务控制语言用于管理数据库的事务
命令包括
COMMIT: Commit command is used to permanently save any transaction
into the database.
ROLLBACK: This command restores the database to last committed state.
It is also used with savepoint command to jump to a savepoint
in a transaction.
SAVEPOINT: Savepoint command is used to temporarily save a transaction so
that you can rollback to that point whenever necessary.
DCL (Data Control Language) :
命令如:
GRANT: allow specified users to perform specified tasks.
REVOKE: cancel previously granted or denied permissions.