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


Please Help Members By Posting Answers For Below Questions

Is insert autocommit in oracle?

785


Explain oracle instance.

886


What is a named program unit?

782


How to name query output columns in oracle?

898


Calculate difference between 2 date / times in oracle sql?

784


Briefly explain what is literal? Give an example where it can be used?

785


how to do daily transactions with out sql* loader control file regesterd in apps?

1423


What is the usage of synonyms?

810


How to use values from other tables in update statements using oracle?

824


How many types of auditing in Oracle?

788


How to change user password in oracle?

803


Point the difference between translate and replace?

816


How to view the tablespaces in the current database?

744


State the difference between a primary key and foreign key?

695


Explain the use of rows option in exp command.

806