ocp-047-98

create table dept (deptno varchar2(10),deptname varchar2(10), constraint pk_deptno primary key (deptno));
create table emp1 (empno varchar2(10),ename varchar2(10),deptno,constraint pk_empno primary key (empno),constraint rf foreign key (deptno) references dept(deptno) )


SQL> select t.owner,
  2         t.constraint_name,
  3         t.table_name,
  4         t.status,
  5         t.deferrable,
  6         t.deferred,
  7         t.validated
  8    from dba_constraints t
  9   where t.owner = 'A'
 10   and t.table_name in ('EMP1','DEPT')
 11   order by t.last_change desc;
 
OWNER                                                        CONSTRAINT_NAME                TABLE_NAME                     STATUS   DEFERRABLE     DEFERRED  VALIDATED
------------------------------------------------------------ ------------------------------ ------------------------------ -------- -------------- --------- -------------
A                                                            RF                             EMP1                           ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED
A                                                            PK_EMPNO                       EMP1                           ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED
A                                                            PK_DEPTNO                      DEPT                           ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED

insert into dept values (10,'it');
insert into dept values (20,'hr');
select * from dept

SQL> select * from dept;
 
DEPTNO     DEPTNAME
---------- ----------
10         it
20         hr
 
insert into emp1 values(1,'KING',10);
insert into emp1 values(2,'HARI',20);
commit;
SQL> select * from emp1;
 
EMPNO      ENAME      DEPTNO
---------- ---------- ----------
1          KING       10
2          HARI       20 
SQL> drop table emp1;
 
Table dropped
 
SQL> flashback table emp1 to before drop;
 
Done
 
SQL> 
SQL> select t.owner,
  2         t.constraint_name,
  3         t.table_name,
  4         t.status,
  5         t.deferrable,
  6         t.deferred,
  7         t.validated
  8    from dba_constraints t
  9   where t.owner = 'A'
 10   and t.table_name in ('EMP1','DEPT')
 11   order by t.last_change desc;
 
OWNER                                                        CONSTRAINT_NAME                TABLE_NAME                     STATUS   DEFERRABLE     DEFERRED  VALIDATED
------------------------------------------------------------ ------------------------------ ------------------------------ -------- -------------- --------- -------------
A                                                            BIN$zvNYd4qnRiaPL75ySONeIA==$0 EMP1                           ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED
A                                                            PK_DEPTNO                      DEPT                           ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED
SQL> INSERT INTO emp1 VALUES (2,'COTT' ,10); 
 
INSERT INTO emp1 VALUES (2,'COTT' ,10)
 
ORA-00001: 违反唯一约束条件 (A.BIN$zvNYd4qnRiaPL75ySONeIA==$0)
 
SQL> INSERT INTO emp1 VALUES (3,'ING', 55); 
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> select * from emp1;
 
EMPNO      ENAME      DEPTNO
---------- ---------- ----------
1          KING       10
2          HARI       20
3          ING        55

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值