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

How to run queries on external tables?

575


What do you mean by a tablespace?

566


How to execute the package in oracle?

574


Define the SGA and: How you would configure SGA for a mid-sized OLTP environment? What is involved in tuning the SGA?

1860


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

1610






How to drop a stored procedure in oracle?

592


Explain drop constraint oracle?

593


what is port in oracle? how is it related to database application.

1443


How to run create database statement?

579


Explain what are the characteristics of data files?

631


what are bitmap indexes? How does they work?

1721


What is Segment Advisor in Oracle?

674


types of indexes and the rationale behind choosing a particular index for a situation.

1986


what is a Nested Loop join?

1568


How do I know if oracle is installed on windows?

488