Home > Database > Mysql Tutorial > Oracle 级联约束

Oracle 级联约束

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:20:29
Original
1300 people have browsed it

为什么pk、和col1 不能DROP SQL CREATE TABLE test2 ( 2 pk NUMBER PRIMARY KEY, 3 fk NUMBER, 4 col1 NUMBER, 5 col2 NUMBER, 6 CONSTRAINT fk_constraint FOREIGN KEY (fk) REFERENCES test2, 7 CONSTRAINT ck1 CHECK (pk 0 and col1 0), 8 CONSTRAINT ck2

为什么pk、和col1 不能DROP

SQL> CREATE TABLE test2 (
  2      pk NUMBER PRIMARY KEY,
  3      fk NUMBER,
  4      col1 NUMBER,
  5      col2 NUMBER,
  6      CONSTRAINT fk_constraint FOREIGN KEY (fk) REFERENCES test2,
  7      CONSTRAINT ck1 CHECK (pk > 0 and col1 > 0),
  8      CONSTRAINT ck2 CHECK (col2 > 0)
  9      )
 10  /                                                                                                                                                                

表已创建。

SQL> ALTER TABLE test2 DROP (pk);
ALTER TABLE test2 DROP (pk)
                        *
第 1 行出现错误:
ORA-12992: 无法删除父项关键字列


SQL> ALTER TABLE test2 DROP (col1);
ALTER TABLE test2 DROP (col1)
                        *
第 1 行出现错误:
ORA-12991: 引用的列处于多列约束条件


SQL> ALTER TABLE test2 DROP (fk);

表已更改。

SQL> alter table test2 drop (col2);

表已更改。

SQL>

实在不理解 ↓

SQL> ALTER TABLE test2 DROP (fk);

表已更改。

SQL> alter table test2 drop (col2);

表已更改。

SQL>

 

为什么pk、和col1 不能DROP
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template