Hi,
Just a quick check. I making some tables using oracle and noticed a few ways of defining keys. Which way is correct? Depending on where i read they are done differently
A PK
Create table bleh
(SomeID NUMBER(6) PRIMARY KEY NOT NULL)
Have also seen it done as follows:
CREATE TABLE Employee
(EmpID NUMBER(4) CONSTRAINT EMPPRIMARYKEY PRIMARY KEY)
A FK
CREATE TABLE STAFF
(BRANCHID REFERENCES BRANCH)
However, have seen it done as follows:
CREATE TABLE BLEHHHH
(Dep_ID NUMBER(4) NOT NULL,
CONSTRAINT EMPFOREIGNKEY1 FOREIGN KEY (Dep_ID) REFERENCES tblDepartment (Dep_ID))
Am unsure whuich way i should be doing this for each table (using oracle v10).
Thanks
EDIT: SQL*Plus seems to allow both methods, giving no errors when creating both ways.
Just a quick check. I making some tables using oracle and noticed a few ways of defining keys. Which way is correct? Depending on where i read they are done differently

A PK
Create table bleh
(SomeID NUMBER(6) PRIMARY KEY NOT NULL)
Have also seen it done as follows:
CREATE TABLE Employee
(EmpID NUMBER(4) CONSTRAINT EMPPRIMARYKEY PRIMARY KEY)
A FK
CREATE TABLE STAFF
(BRANCHID REFERENCES BRANCH)
However, have seen it done as follows:
CREATE TABLE BLEHHHH
(Dep_ID NUMBER(4) NOT NULL,
CONSTRAINT EMPFOREIGNKEY1 FOREIGN KEY (Dep_ID) REFERENCES tblDepartment (Dep_ID))
Am unsure whuich way i should be doing this for each table (using oracle v10).
Thanks
EDIT: SQL*Plus seems to allow both methods, giving no errors when creating both ways.

Last edited: