Это будет довольно длинный ответ, так как я показываю, что происходит в разных версиях базы данных.
Вы заметите, что все они ведут себя одинаково:
- ограничение внешнего ключа может быть установлено на
cascade
и set null
, и они оба отображаются в user_constraints.delete_rule
столбец no action
является недопустимым параметром (поэтому вы не можете ожидать, что увидите что-либо в delete_rule
)
Вот так:
12c
SQL> select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
PL/SQL Release 12.2.0.1.0 - Production 0
CORE 12.2.0.1.0 Production
TNS for Linux: Version 12.2.0.1.0 - Production 0
NLSRTL Version 12.2.0.1.0 - Production 0
SQL> create table your_table (id number primary key);
Table created.
SQL> create table my_table (id number);
Table created.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete cascade;
Table altered.
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
DELETE_RU
---------
CASCADE
SQL> alter table my_table drop constraint fk_my_your;
Table altered.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete set null;
Table altered.
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
DELETE_RU
---------
SET NULL
SQL> alter table my_table drop constraint fk_my_your;
Table altered.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete no action;
references your_table (id) on delete no action
*
ERROR at line 2:
ORA-00905: missing keyword
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
no rows selected
11 г
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
SQL> create table your_table (id number primary key);
Table created.
SQL> create table my_table (id number);
Table created.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete cascade;
Table altered.
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
DELETE_RU
---------
CASCADE
SQL> alter table my_table drop constraint fk_my_your;
Table altered.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete set null;
Table altered.
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
DELETE_RU
---------
SET NULL
SQL> alter table my_table drop constraint fk_my_your;
Table altered.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete no action;
references your_table (id) on delete no action
*
ERROR at line 2:
ORA-00905: missing keyword
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
no rows selected
10 г
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for 64-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> create table your_table (id number primary key);
Table created.
SQL> create table my_table (id number);
Table created.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete cascade;
Table altered.
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
DELETE_RU
---------
CASCADE
SQL> alter table my_table drop constraint fk_my_your;
Table altered.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete set null;
Table altered.
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
DELETE_RU
---------
SET NULL
SQL> alter table my_table drop constraint fk_my_your;
Table altered.
SQL> alter table my_table add constraint fk_my_your foreign key (id)
2 references your_table (id) on delete no action;
references your_table (id) on delete no action
*
ERROR at line 2:
ORA-00905: missing keyword
SQL> select delete_rule from user_constraints where constraint_name = 'FK_MY_YOUR';
no rows selected