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
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / durgarao k
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 ? | 1 Yes | 0 No |
What are the types of trigger in oracle?
Explain the function of optimizer in oracle?
How can we view last record added to a table?
how to find full database size
1 Answers BirlaSoft, Consultancy,
One Table having two rows with one colomn having values Like"Male" and "Female". how to upadte these values Like "Female" and "Male" in single update statement.
What is the difference between implicit index and explicit index?
What is a nested table and how is it different from a normal table?
How to compare dates in oracle sql?
Define oracle database
How to export several tables together?
Query to get max and second max in oracle in one query ?
34 Answers CTS, Keane India Ltd, TCS, Wipro,
difference between bind variable and variable