Create table Employee
(
Employee_Id varchar2(8) Constraint emp_id_pk primary key,
FirstName varchar2(50),
LastName varchar2(50),
DeptID Number(5)
Constraint dept_id_fk Foreign Key(DeptId)
References Department(DeptId)
)
Error I am getting: Constraint specification are not
allowed here
Answer Posted / durgarao k
There are two ways in specifying constraints
Table level and Column level
In your question you specified Foreign key constraint as column level constraint.so, at that time you write as
Create table Employee
(
Employee_Id varchar2(8) Constraint emp_id_pk primary key,
FirstName varchar2(50),
LastName varchar2(50),
DeptID Number(5)
Constraint dept_id_fk
References Department(DeptId)
)
if you want to specify Foreign key constraint at table level
you just do as
Create table Employee
(
Employee_Id varchar2(8) Constraint emp_id_pk primary key,
FirstName varchar2(50),
LastName varchar2(50),
DeptID Number(5),
Constraint dept_id_fk Foreign Key(DeptId)
References Department(DeptId)
)
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is java oracle used for?
What are the oracle differences between nvl and coalesce
What is data block in Oracle?
What is a table in oracle?
Can we write insert statement in function in oracle?
What is truncate oracle?
What is oracle datasource?
How would you best determine why your MVIEW couldnt FAST REFRESH?
What are transaction isolation levels supported by oracle?
What is sharded cluster?
What is translate in oracle?
What is archive log in Oracle?
How to define a variable of a specific record type?
How do I use unicode codesets with the weblogic jdriver for oracle driver?
Is oracle an operator?