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 |
How to manage transaction isolation level?
What are the ansi data types supported in oracle?
How to connect to the server with user account: sys?
how many triggers we can create on a table
11 Answers G2 Technology, TCS,
emp numb is unique because that is primary key,,but what is foreign key .. explain very clear with example
How to convert dates to characters in oracle?
How do I spool to a csv formatted file using sqlplus?
What is the difference between substr & instr functions?
What is not equal to in oracle?
How to get maxsal , minsal, ename department wise in single query
how to produce numbers from 1 to 10 using dual table
In XIR2 if we lost the administration password .How can we regain the password?thanks in advance.