--添加约束
alter table emp add constraint pk_emp primary key (empid);
alter table emp add constraint fk_emp foreign key (empnum);
alter table emp add constraint ck_emp check (salary <= 25000);
alter table emp add constraint uk_emp unique (grp_id);
alter table emp modify (lastname not null);
--关闭打开约束
alter table emp disable|enable primary key;
alter table emp disable|enable constraint uk_emp;
--删除约束
alter table emp drop unique (grp_id);
alter table emp drop primary key (empid);
alter table emp drop constraint ck_emp;
alter table emp modify (lastname null);
alter table emp cascade constraints; --引用所删除表的其它表的约束被删除
操作数据库数据
insert into emp (select * from test_emp);
事务
set transaction [read only] --开始事务,可选
commit
rollback
savepoint point_name
rollback to savepoint point_name
视图
create [or replace] view emp_view as (select * from emp where jpb='Ana');
drop view emp_view;
alter table emp add constraint pk_emp primary key (empid);
alter table emp add constraint fk_emp foreign key (empnum);
alter table emp add constraint ck_emp check (salary <= 25000);
alter table emp add constraint uk_emp unique (grp_id);
alter table emp modify (lastname not null);
--关闭打开约束
alter table emp disable|enable primary key;
alter table emp disable|enable constraint uk_emp;
--删除约束
alter table emp drop unique (grp_id);
alter table emp drop primary key (empid);
alter table emp drop constraint ck_emp;
alter table emp modify (lastname null);
alter table emp cascade constraints; --引用所删除表的其它表的约束被删除
操作数据库数据
insert into emp (select * from test_emp);
事务
set transaction [read only] --开始事务,可选
commit
rollback
savepoint point_name
rollback to savepoint point_name
视图
create [or replace] view emp_view as (select * from emp where jpb='Ana');
drop view emp_view;