Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

primary or unique 1

Status
Not open for further replies.

props

Technical User
Nov 22, 2003
17
GB
i have a table named publisher with Publ_IDNo the primary key
in every raw must be the same.
using insert into publisher the first raw created succesfully the second insert into table gave me a
ORA-00001: unique constraint (SCOTT.SYS_C003035) violated

Any advice

thanks
 
if it is the primary key then it for every row, it MUST be different!
 
cn i have just one raw in a table ? with only the primary
key ? instead of writing it 5 times ??
 
>cn i have just one raw in a table ?

You can have as many rows as you want as long as the Publ_IDNo is unique in each one of them.

>with only the primary key ?

this depends on wheather the rest of the fields accept nulls or not.

>instead of writing it 5 times ??

why would you write it 5 times? I don't completely understand your question... It may be better if you could provide more details of the structure of the table and what you want to do (fields, queries etc)
 
Publ_IDNo Publ_Name Publ_Address Publ_Tel Publ_VATno
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
1 Wesley 21 Edinburgh rd 1234598754 604577
this is what im trying to insert
 
as i told you in my previous post, Publ_IDNo should be different in each row. so this will be ok:

Publ_IDNo Publ_Name Publ_Address Publ_Tel Publ_VATno
1 Wesley 21 Edinburgh rd 1234598754 604577
2 Wesley 21 Edinburgh rd 1234598754 604577
3 Wesley 21 Edinburgh rd 1234598754 604577
4 Wesley 21 Edinburgh rd 1234598754 604577
5 Wesley 21 Edinburgh rd 1234598754 604577
6 Wesley 21 Edinburgh rd 1234598754 604577
7 Wesley 21 Edinburgh rd 1234598754 604577
8 Wesley 21 Edinburgh rd 1234598754 604577
9 Wesley 21 Edinburgh rd 1234598754 604577
10 Wesley 21 Edinburgh rd 1234598754 604577
11 Wesley 21 Edinburgh rd 1234598754 604577
12 Wesley 21 Edinburgh rd 1234598754 604577
13 Wesley 21 Edinburgh rd 1234598754 604577
14 Wesley 21 Edinburgh rd 1234598754 604577
15 Wesley 21 Edinburgh rd 1234598754 604577
16 Wesley 21 Edinburgh rd 1234598754 604577
17 Wesley 21 Edinburgh rd 1234598754 604577
18 Wesley 21 Edinburgh rd 1234598754 604577
19 Wesley 21 Edinburgh rd 1234598754 604577
20 Wesley 21 Edinburgh rd 1234598754 604577

may I ask why do you want to insert the same record so many times?
 
the thing is there is one publisher with the same id number
so i guess must be always 1

am i right?

thanks for the help
 
yep, but why do you want 20 records just for 1 publisher? one record should be enough!
 
so you recommend tha is fine ok????

il try what you saying then

Thank you very much indeed!
 
it is fine as long as you have different IDs for each record. and yes, one record for each publisher is enough. If you have any more problems please post back.

regards,
nicsin
 
im creating the book table which keeps a foreign key from the publisher table
is that corect ??

create table Book(Book_ISBN varchar(10) not null,
Book_Title varchar(20),
Book_DatePub varchar(10),
Book_Edition varchar(10),
Book_Type varchar(15)
Book_Author varchar(20),
primary key (Book_ISBN),
Publ_IDNo varchar(8),
foreign key (Publ_IDNo) references Publisher(Publ_IDNo));
 
I think it will be better if you tried it yourself first.

I usually create constraints using an alter table command so I assign a name myself.

 
btw is this part of a coursework? If yes, please read faq222-2244 and especially paragraph 10.
 
yes this is part of a coursework .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top