Created
January 6, 2012 08:28
-
-
Save batmat/1569693 to your computer and use it in GitHub Desktop.
FK constraint creation sample (Oracle)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "TESTTABLEPARENT" | |
( | |
"A" VARCHAR2(20 BYTE) NOT NULL ENABLE, | |
"B" VARCHAR2(20 BYTE) NOT NULL ENABLE, | |
"C" DATE, | |
CONSTRAINT "TESTTABLEPARENT_PK" PRIMARY KEY ("A", "B") | |
) | |
CREATE TABLE "TESTTABLEENFANT" | |
( | |
"INFO_BLABLA" VARCHAR2(20 BYTE), | |
"FK_A" VARCHAR2(20 BYTE), | |
"FK_B" VARCHAR2(20 BYTE), | |
CONSTRAINT "FKC_TESTTABLEPARENT" FOREIGN KEY ("FK_A", "FK_B") REFERENCES TESTTABLEPARENT" ("A", "B") ENABLE | |
) | |
// Or creating the constraint afterwards from ...ENFANT to ...PARENT | |
alter table "TESTTABLEENFANT" add constraint FKC_TESTTABLEPARENT foreign key("FK_A","FK_B") references "TESTTABLEPARENT"("A","B") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment