Home » SQL & PL/SQL » SQL & PL/SQL » composite primary key
composite primary key [message #204729] Tue, 21 November 2006 22:14 Go to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
hello team

i m creating a table having composite primary key but there is an error which i unable to predicate.
please help me out by this problem.

SQL> create table train_mas_new (
2 train_no number,
3 name varchar2(20),
4 source varchar2(20),
5* dest varchar2(20) constraint cons_com_pr_key primary key (train_no, name, source, dest))
SQL> /
dest varchar2(20) constraint cons_com_pr_key primary key (train_no, name, source, dest))
*
ERROR at line 5:
ORA-00907: missing right parenthesis


thanxx
with regards
ashish
Re: composite primary key [message #204746 is a reply to message #204729] Tue, 21 November 2006 23:17 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
hi,


and does this help.
create table train_mas_new (
train_no number,
name varchar2(20),
source varchar2(20),
dest varchar2(20) ,
constraint cons_com_pr_key primary key(train_no, name, source, dest)
)



regards,
Re: composite primary key [message #204747 is a reply to message #204729] Tue, 21 November 2006 23:17 Go to previous messageGo to next message
rameshuddaraju
Messages: 69
Registered: June 2005
Location: India
Member

composite primary key can be created as only a table constraint

so you have to separate dest varchar2(20) and your constraint as below
create table train_mas_new (
train_no number,
name varchar2(20),
source varchar2(20),
dest varchar2(20), constraint cons_com_pr_key primary key (train_no, name, source, dest))

[Updated on: Tue, 21 November 2006 23:18]

Report message to a moderator

Re: composite primary key [message #204750 is a reply to message #204729] Tue, 21 November 2006 23:20 Go to previous messageGo to next message
romi
Messages: 67
Registered: October 2006
Member

Write ur query like :-

create table train_mas_new (
train_no number,
name varchar2(20),
source varchar2(20),
dest varchar2(20), constraint cons_com_pr_key primary key (train_no, name, source, dest));


u r missing comma(,).
Re: composite primary key [message #204755 is a reply to message #204729] Tue, 21 November 2006 23:55 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
thanxx to u all

with regards
ashish Cool
Re: composite primary key [message #204766 is a reply to message #204729] Wed, 22 November 2006 01:02 Go to previous messageGo to next message
moparthy99
Messages: 13
Registered: July 2006
Junior Member
Add , after dest varchar(),contratint name of constraint(list cols)
Re: composite primary key [message #204791 is a reply to message #204766] Wed, 22 November 2006 02:22 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Don't you think that was clear after three people pointed that out?
Previous Topic: SQL query help
Next Topic: combine the OR
Goto Forum:
  


Current Time: Sat Dec 10 10:49:09 CST 2016

Total time taken to generate the page: 0.12238 seconds