表操作:
create table student (sid int primary key, sname varchar(10), sex char(1) check(sex in('m','w')), age int); #创建表
alter table student rename to s; #修改表名称
drop table student; #删除表
修改表:
alter table student add classid varchar(15); #增加列
alter table student drop column classid; #删除列
alter table student modify classid varchar(5); #修改列
修改表约束:
alter table student add constraint p_name primary key(sid); #添加主键约束
******************************************************************
create table s (sno int, sname varchar(10), sex char(2), age int); #创建表
alter table s add classid varchar(5);
alter table s add deptno varchar(5);
alter table s modify classid int;
alter table s rename column classid to classbh;
alter table s drop (classbh, deptno);
alter table s add constraint sname_unique unique(sname);
alter table s add constraint age_check CHECK(age>=0 and age<=100);
select constraint_name, constraint_type from user_constraints where table_name = 'S';
alter table s drop constraint sname_unique;
alter table s modify (sname not null);