1、创建表
create table table_name(
attribute_name_1 data_type [not null],
attribute_name_2 data_type,
attribute_name_3 data_type,
...........
primary key(primary_key),
foreign key(foreign_key) references (another_table_name)
);
2、删除表
delete from table_name where P;//删除表中所有元组
drop table table_name;//删除整个表包括属性
3、增删表的属性
alter table table_name add attribute_name data_type;//增加属性并设置数据类型
alter table table_name drop attribute_name;//删除一个属性
4、为表添加一个元组
insert into table_name(属性1,属性2,属性3,……)
values('value_1','value_2',value_3',……);
//不指定属性顺序的话按表的默认属性顺序插入数据
insert into table_name
子查询;
//将子查询的结果插入到表中
5、改变表中某条属性的值
update table_name
set attribute_name = [数据]
[where P];
6、case语句
case
when p_1 then result_1;
when p_2 then result_2;
……………………
when p_i then result_i;
else result_0;
end依次判断布尔值p_i是否为真,如果是则返回result_i,否则继续判断,如果没有一个为真则返回result_0。整个case语句相当于一个值