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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on SQL command

Status
Not open for further replies.

jain747

Technical User
Apr 22, 2003
17
US
I have a question on the "Test" keyword. Example where Test is used:

CREATE TABLE BOOKS
(ISBN TEXT(13) CONSTRAINT PrimaryKeyName PRIMARY KEY,
TITLE TEXT(100),
PRICE MONEY,
PubID TEXT(10) CONSTRAINT Test FOREIGN KEY(PubID) REFERENCES
PUBLISHERS
(PubID));

Whats the reason for "CONSTRAINT Test"? When using PubID again as a foreign key in another table I got an error saying "There is already a relationship named 'Test' in the current database." Two questions: Is there no way to use the Test keyword in another table and whats another way to declare a foreign key in SQL code? Thanks.
 
The only problem is the name. Call it fk_BOOKS_test or something else so that you can have a unique constraint name.

Likewise using PrimaryKeyName as a primary key name is not such a great idea. How about PK_BOOKS_ISBN.


JHall
 
it works and I understand what you mean...thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top