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
Is insert autocommit in oracle?
Explain oracle instance.
What is a named program unit?
How to name query output columns in oracle?
Calculate difference between 2 date / times in oracle sql?
Briefly explain what is literal? Give an example where it can be used?
how to do daily transactions with out sql* loader control file regesterd in apps?
What is the usage of synonyms?
How to use values from other tables in update statements using oracle?
How many types of auditing in Oracle?
How to change user password in oracle?
Point the difference between translate and replace?
How to view the tablespaces in the current database?
State the difference between a primary key and foreign key?
Explain the use of rows option in exp command.