Foreign key创建前提 Primay key 可以disable,但必须要有

SQL>

SQL> alter table A

2 drop constraint ABCD primary key (A)

3 disable

4 novalidate;

alter table A

drop constraint ABCD primary key (A)

disable

novalidate

ORA-01735: invalid ALTER TABLE option

SQL>

SQL> alter table A

2 drop constraint ABCD primary key (A)

3 disable

4 novalidate;

alter table A

drop constraint ABCD primary key (A)

disable

novalidate

ORA-01735: invalid ALTER TABLE option

SQL>

SQL> alter table A

2 drop constraint ABCD

3 ;

alter table A

drop constraint ABCD

ORA-02273: this unique/primary key is referenced by some foreign keys

SQL>

SQL> alter table B

2 drop constraint abc

3 ;

alter table B

add constraint abc

ORA-00931: missing identifier

SQL> alter table B drop constraint abc;

Table altered

SQL>

SQL> alter table B

2 add constraint abc foreign key (A)

3 references a (A)

4 disable

5 novalidate;

Table altered

SQL> alter table B drop constraint abc;

Table altered

SQL> alter table A drop constraint ABCD;

Table altered

SQL> alter table B add constraint abc foreign key (A) references a (A) disable novalidate;

alter table B add constraint abc foreign key (A) references a (A) disable novalidate

ORA-02270: no matching unique or primary key for this column-list

SQL>

SQL> alter table A

2 add constraint ABCD primary key (A)

3 disable

4 novalidate;

Table altered

SQL> alter table B add constraint abc foreign key (A) references a (A) disable novalidate;

Table altered

SQL>

相关推荐
OLDERHARD7 小时前
Java - MyBatis(上)
java·oracle·mybatis
bug菌¹1 天前
滚雪球学Oracle[1.3讲]:Oracle数据库架构基础
数据库·oracle·数据库架构
bug菌¹1 天前
滚雪球学Oracle[2.1讲]:Oracle数据库安装与配置
数据库·oracle
wdxylb1 天前
MySQL数据库用户权限控制的实现方法
数据库·mysql·oracle
bug菌¹1 天前
滚雪球学Oracle[6.1讲]:高级特性与实战案例
数据库·oracle
文牧之1 天前
PostgreSQL 和Oracle 表压缩的对比
运维·数据库·postgresql·oracle
bug菌¹1 天前
滚雪球学Oracle[1.1讲]:Oracle数据库基础概念
数据库·oracle
爱吃牛肉的大老虎1 天前
Oracle架构之表空间详解
数据库·oracle·架构
运维之美@1 天前
oracle数据备份和导入
数据库·oracle
jnrjian2 天前
Oracle datafile 数目限制是多少
数据库·oracle