Oracle processes null. Simply put, if multiple columns are unique and contain more than one null, Oracle requires columns not null to be unique.
However, this method is not used for foreign key processing:
SQL> Create Table t_p (ID number, name varchar2 (30), constraint pk_t_p primary K
Ey (ID, name ));
Table created.
SQL> Create Table T_c (ID number, f_id number, f_name varchar2 (30 ),
2 constraint fk_t_c foreign key (f_id, f_name) References t_p );
Table created.
SQL> insert into t_p values (1, 'A ');
1 row created.
SQL> insert into T_c values (1, 1, 'A ');
1 row created.
SQL> insert into T_c values (1, 1, 'B ');
Insert into T_c values (1, 1, 'B ')
*
Error at line 1:
ORA-02291: Integrity Constraint (Scott. fk_t_c) violated-parent key not found
SQL> insert into T_c values (1, null, 'B ');
1 row created.
SQL> insert into T_c values (1, null, 'B ');
1 row created.
SQL> select * From T_c;
Id f_id f_name
--------------------------------------------------
1 1
1 B
1 B
SQL>
As you can see, the f_id column is empty, so that Oracle no longer checks whether other columns meet the foreign key constraints, so that this record is directly inserted into the subtable.
Generally, the combination of Foreign keys is rarely used, so this problem has never been noticed before. This description is only available at the time of reading the document.
This article does not discuss whether such an implementation is justified. At least Oracle thinks that this implementation is justified, and it has already been implemented in this way, and we cannot change it. What we can do is to carefully consider whether to allow the foreign key column to be empty when using the composite foreign key.