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
How to run queries on external tables?
What do you mean by a tablespace?
How to execute the package in oracle?
Define the SGA and: How you would configure SGA for a mid-sized OLTP environment? What is involved in tuning the SGA?
22. Display the order number, number of lines in the order, total number of items and total value for all orders that have a total value greater than $100
How to drop a stored procedure in oracle?
Explain drop constraint oracle?
what is port in oracle? how is it related to database application.
How to run create database statement?
Explain what are the characteristics of data files?
what are bitmap indexes? How does they work?
What is Segment Advisor in Oracle?
types of indexes and the rationale behind choosing a particular index for a situation.
what is a Nested Loop join?
How do I know if oracle is installed on windows?