创建表
create table test01(
id int not null,
name varchar(8) not null,
gender varchar2(2) not null,
age int not null,
address varchar2(20) default ‘地址不详’ not null,
regdata date
);
修改表
alter table test01 add constraint s_id primary key;
alter table test01 add constraint CK_INFOS_GENDER check(gender=’男’ or gender=’女’)
alter table test01 add constraint CK_INFOS_AGE(age>=0 and age<=50)
alter table 表名 modify 字段名 default 默认值; //更改字段类型
alter table 表名 add 列名 字段类型; //增加字段类型
alter table 表名 drop column 字段名; //删除字段名
alter table 表名 rename column 列名 to 列名 //修改字段名
rename 表名 to 表名 //修改表名
删除表
truncate table 表名 //删除表中的所有数据,速度比delete快很多,截断表
delete from table 条件//
drop table 表名 //删除表
插入语句
insert into 表名(值1,值2) values(值1,值2);
修改语句
update 表名 set 字段=值 [修改条件]
查询语句