Mismatch in data length of columns involved in referential integrity constraint [message #394454] |
Fri, 27 March 2009 04:13 |
shweta.s
Messages: 2 Registered: March 2009
|
Junior Member |
|
|
It is found that the foreign key constraint is allowed to create even if the column in referred (parent) table is having different data length than the column in referring (child) table.
Example:
1. DDL for parent table:
CREATE TABLE TABLE_1
(
TAB_1_COL_1 NUMBER(3,6) PRIMARY KEY,
TAB_1_COL_2 VARCHAR2(40 BYTE) UNIQUE
);
2. DDL for child table:
CREATE TABLE TABLE_2
(
TAB_2_COL_1 NUMBER(3,10),
TAB_2_COL_2 VARCHAR2(30 BYTE),
CONSTRAINT FK_CONST_1 FOREIGN KEY (TAB_2_COL_1) REFERENCES TABLE_1(TAB_1_COL_1),
CONSTRAINT FK_CONST_2 FOREIGN KEY (TAB_2_COL_2) REFERENCES TABLE_1(TAB_1_COL_2)
);
Above tables are created with no error.
In case of the constraint 'FK_CONST_1', precision values in the number columns are different. For the constraint 'FK_CONST_2' data length of the varchar2 columns are different.
[Updated on: Fri, 27 March 2009 04:20] Report message to a moderator
|
|
|
|
|
|
|
|
|