習SQL語句之SQL語句大全

2022-05-05 11:15:13 字數 1076 閱讀 1419

--語 句 功 能

--資料操作

select --從資料庫表中檢索資料行和列

insert --向資料庫表新增新資料行

delete --從資料庫表中刪除資料行

update --更新資料庫表中的資料

--資料定義

create table --建立乙個資料庫表

drop table --從資料庫中刪除表

alter table --修改資料庫表結構

create view --建立乙個檢視

drop view --從資料庫中刪除檢視

create index --為資料庫表建立乙個索引

drop index --從資料庫中刪除索引

create procedure --建立乙個儲存過程

drop procedure --從資料庫中刪除儲存過程

create trigger --建立乙個觸發器

drop trigger --從資料庫中刪除觸發器

create schema --向資料庫新增乙個新模式

drop schema --從資料庫中刪除乙個模式

create domain --建立乙個資料值域

alter domain --改變域定義

drop domain --從資料庫中刪除乙個域

--資料控制

grant --授予使用者訪問許可權

deny --拒絕使用者訪問

revoke --解除使用者訪問許可權

--事務控制

commit --結束當前事務

rollback --中止當前事務

set transaction --定義當前事務資料訪問特徵

--程式化sql

declare --為查詢設定游標

explan --為查詢描述資料訪問計畫

open --檢索查詢結果開啟乙個游標

fetch --檢索一行查詢結果

close --關閉游標

prepare --為動態執行準備sql 語句

execute --動態地執行sql 語句

describe --描述準備好的查詢

《SQL語句大全》

語 句 功 能 資料操作 select 從資料庫表中檢索資料行和列 insert 向資料庫表新增新資料行 delete 從資料庫表中刪除資料行 update 更新資料庫表中的資料 資料定義 create table 建立乙個資料庫表 drop table 從資料庫中刪除表 alter table 修...

SQL語句大全

建表 create table tab1 id counter,name string,age integer,date datetime 技巧 自增字段用 counter 宣告.欄位名為關鍵字的字段用方括號括起來,數字作為欄位名也可行.建立索引 下面的語句在tab1的date列上建立可重複索引 c...

SQL語句大全 技巧

三 技巧 1 1 1,1 2的使用,在sql語句組合時用的較多 where 1 1 是表示選擇全部 where 1 2 全部不選,如 if strwhere begin set strsql select count as total from tblname where strwhere ende...