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



Create table Employee ( Employee_Id varchar2(8) Constraint emp_id_pk primary key, FirstName var..

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

Create table Employee ( Employee_Id varchar2(8) Constraint emp_id_pk primary key, FirstName var..

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

Post New Answer

More Oracle General Interview Questions

How to manage transaction isolation level?

0 Answers  


What are the ansi data types supported in oracle?

0 Answers  


How to connect to the server with user account: sys?

0 Answers  


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

1 Answers  


How to convert dates to characters in oracle?

0 Answers  


How do I spool to a csv formatted file using sqlplus?

0 Answers  


What is the difference between substr & instr functions?

0 Answers  


What is not equal to in oracle?

0 Answers  


How to get maxsal , minsal, ename department wise in single query

0 Answers  


how to produce numbers from 1 to 10 using dual table

4 Answers   Genpact,


In XIR2 if we lost the administration password .How can we regain the password?thanks in advance.

0 Answers   IBM,


Categories
  • Oracle General Interview Questions Oracle General (1808)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)