当前位置:Gxlcms > 数据库问题 > SQL 语言分类

SQL 语言分类

时间:2021-07-01 10:21:17 帮助过:3人阅读

DDL

  Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:

  CREATE - to create objects in the database

  ALTER - alters the structure of the database

  DROP - delete objects from the database

  TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed

  COMMENT - add comments to the data dictionary

  RENAME - rename an object

DML

  Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:

  SELECT - retrieve data from the a database

  INSERT - insert data into a table

  UPDATE - updates existing data within a table

  DELETE - deletes all records from a table, the space for the records remain

  MERGE - UPSERT operation (insert or update)

  CALL - call a PL/SQL or Java subprogram

  EXPLAIN PLAN - explain access path to data

  LOCK TABLE - control concurrency

DCL

  Data Control Language (DCL) statements. Some examples:

  GRANT - gives user‘s access privileges to database

  REVOKE - withdraw access privileges given with the GRANT command

TCL

  Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

  COMMIT - save work done

  SAVEPOINT - identify a point in a transaction to which you can later roll back

  ROLLBACK - restore database to original since the last COMMIT

  SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use



2.其他数据主流分法:
 数据查询语言DQL
数据查询语言DQL基本结构是由SELECT子句,FROM子句,WHERE
子句组成的查询块:
SELECT <字段名表>
FROM <表或视图名>
WHERE <查询条件>

数据操纵语言
数据操纵语言DML主要有三种形式:
1) 插入:INSERT
2) 更新:UPDATE
3) 删除:DELETE

 数据定义语言DDL
数据定义语言DDL用来创建数据库中的各种对象-----表、视图、
索引、同义词、聚簇等如:
CREATE TABLE/VIEW/INDEX/SYN/CLUSTER
| | | | |
表 视图 索引 同义词 簇

数据控制语言DCL
数据控制语言DCL用来授予或回收访问数据库的某种特权,并控制
数据库操纵事务发生的时间及效果,对数据库实行监视等。如:
1) GRANT:授权。


2) ROLLBACK [WORK] TO [SAVEPOINT]:回退到某一点。
回滚---ROLLBACK
回滚命令使数据库状态回到上次最后提交的状态。其格式为:
SQL>ROLLBACK;


3) COMMIT [WORK]:提交。


    在数据库的插入、删除和修改操作时,只有当事务在提交到数据
库时才算完成。在事务提交前,只有操作数据库的这个人才能有权看
到所做的事情,别人只有在最后提交完成后才可以看到。
提交数据有三种类型:显式提交、隐式提交及自动提交。下面分
别说明这三种类型。


(1) 显式提交
用COMMIT命令直接完成的提交为显式提交。其格式为:
SQL>COMMIT;


(2) 隐式提交
用SQL命令间接完成的提交为隐式提交。这些命令是:
ALTER,AUDIT,COMMENT,CONNECT,CREATE,DISCONNECT,DROP,
EXIT,GRANT,NOAUDIT,QUIT,REVOKE,RENAME。


(3) 自动提交
若把AUTOCOMMIT设置为ON,则在插入、修改、删除语句执行后,
系统将自动进行提交,这就是自动提交。其格式为:
SQL>SET AUTOCOMMIT ON;

SQL 语言分类

标签:

人气教程排行