SQL语句语法
(1)alter table:更新已存在表的结构
alter table table_name (add|drop|modify column datatype, ...);
(2)commit:将事物写入数据库
commit [transaction];
(3)create index:在一个或者多个列上创建索引
create index index_name on table_name (column, ...);
(4)create procedure:创建存储过程
create procedure procedure_name(params)
(5)create table:创建新数据库表
create table table_name (column datatype, ...);
(6)create view:创建视图
create view view_name as select columns, ... from tables, ...;
(7)delete:从表中删除一行或者多行
delete from table_name [where ...];
(8)drop:永久删除数据库对象(表、视图、索引等)
drop index|procedure|table|view index_name|procedure_name|table_name|view_name;
(9)insert:向表中插入一行
insert into table_name [(columns, ....)] values (values, ...);
(10)insert select:将select的结果插入到一个表中,实现多行插入
insert into table_name [(columns, ...)] select columns, ... from table_name, ...;
(11)rollback:撤销一个事物块
rollback [to save_point_name];
(12)select:从表中检索数据
select column_name, ... from table_name, ...;
(13)select into:复制表数据,可以不用事先创建新表
select * into to_table from from_table;
(14)update:更新表中的一行或者多行数据
update table_name set columns=value, ... [where ...];
批量更新,示例如下:
update table_name
set column1 = case some_column
when some_column_case1 then value11
when some_column_case2 then value12
end,
column2 = case some_column
when some_column_case1 then value21
when some_column_case2 then value22
end
where some_column in (some_column_case1, some_column_case2);