DDL :數(shù)據(jù)定義語(yǔ)言,用于定義和管理 SQL 數(shù)據(jù)庫(kù)中的所有對(duì)象的語(yǔ)言
1.CREATE – to create objects in the database 創(chuàng)建數(shù)據(jù)庫(kù)對(duì)象
2.ALTER – alters the structure of the database 修改數(shù)據(jù)庫(kù)對(duì)象
3.DROP – delete objects from the database 刪除數(shù)據(jù)庫(kù)對(duì)象
4.TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
TRUNCATE TABLE [Table Name]。
下面是對(duì)Truncate語(yǔ)句在MSSQLServer2000中用法和原理的說(shuō)明:
Truncate table 表名 速度快,而且效率高,因?yàn)?
TRUNCATE TABLE 在功能上與不帶 WHERE 子句的 DELETE 語(yǔ)句相同:二者均刪除表中的全部行。但 TRUNCATE TABLE 比 DELETE 速度快,且使用的系統(tǒng)和事務(wù)日志資源少。
DELETE 語(yǔ)句每次刪除一行,并在事務(wù)日志中為所刪除的每行記錄一項(xiàng)。TRUNCATE TABLE 通過(guò)釋放存儲(chǔ)表數(shù)據(jù)所用的數(shù)據(jù)頁(yè)來(lái)刪除數(shù)據(jù),并且只在事務(wù)日志中記錄頁(yè)的釋放。
TRUNCATE TABLE 刪除表中的所有行,但表結(jié)構(gòu)及其列、約束、索引等保持不變。新行標(biāo)識(shí)所用的計(jì)數(shù)值重置為該列的種子。如果想保留標(biāo)識(shí)計(jì)數(shù)值,請(qǐng)改用 DELETE。如果要?jiǎng)h除表定義及其數(shù)據(jù),請(qǐng)使用 DROP TABLE 語(yǔ)句。
對(duì)于由 FOREIGN KEY 約束引用的表,不能使用 TRUNCATE TABLE,而應(yīng)使用不帶 WHERE 子句的 DELETE 語(yǔ)句。由于 TRUNCATE TABLE 不記錄在日志中,所以它不能激活觸發(fā)器。
TRUNCATE TABLE 不能用于參與了索引視圖的表。
5.COMMENT – add comments to the data dictionary 注釋
6.GRANT – gives user’s access privileges to database 授權(quán)
7.REVOKE – withdraw access privileges given with the GRANT command 收回已經(jīng)授予的權(quán)限
DML:數(shù)據(jù)操作語(yǔ)言,SQL中處理數(shù)據(jù)等操作統(tǒng)稱為數(shù)據(jù)操縱語(yǔ)言
1.SELECT – retrieve data from the a database 查詢數(shù)據(jù)
2.INSERT – insert data into a table 添加數(shù)據(jù)
3.UPDATE – updates existing data within a table 更新數(shù)據(jù)
4.DELETE – deletes all records from a table, the space for the records remain 刪除
5.CALL – call a PL/SQL or Java subprogram
6.EXPLAIN PLAN – explain access path to data
Oracle RDBMS執(zhí)行每一條SQL語(yǔ)句,都必須經(jīng)過(guò)Oracle優(yōu)化器的評(píng)估。所以,了解優(yōu)化器是如何選擇(搜索)路徑以及索引是如何被使用的,對(duì)優(yōu)化SQL語(yǔ)句有很大的幫助。Explain可以用來(lái)迅速方便地查出對(duì)于給定SQL語(yǔ)句中的查詢數(shù)據(jù)是如何得到的即搜索路徑(我們通常稱為Access Path)。從而使我們選擇最優(yōu)的查詢方式達(dá)到最大的優(yōu)化效果。
7.LOCK TABLE – control concurrency 鎖,用于控制并發(fā)
DCL:數(shù)據(jù)控制語(yǔ)言,用來(lái)授予或回收訪問(wèn)數(shù)據(jù)庫(kù)的某種特權(quán),并控制數(shù)據(jù)庫(kù)操縱事務(wù)發(fā)生的時(shí)間及效果,對(duì)數(shù)據(jù)庫(kù)實(shí)行監(jiān)視等
COMMIT – save work done 提交
SAVEPOINT – identify a point in a transaction to which you can later roll back 保存點(diǎn)
ROLLBACK – restore database to original since the last COMMIT 回滾
SET TRANSACTION – Change transaction options like what rollback segment to use 設(shè)置當(dāng)前事務(wù)的特性,它對(duì)后面的事務(wù)沒(méi)有影響.