If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Duplicate Values in mysql database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-10, 05:10
seanog2001 seanog2001 is offline
Registered User
 
Join Date: Oct 2010
Posts: 1
Duplicate Values in mysql database

Hi,

I was wondering is it possible to ensure that their cant be duplicate fields on non primary fields? i can ensure that primary keys cant be duplicated but i was wondering can other fields be set so they cant be duplicated?

okay so for example:

i have a store table and a site table

Store
Store_id(PK)
Store_site_id(FK)
Router number(unique key cant be the same)

Site
site_id(pk)
store_site
Reply With Quote
  #2 (permalink)  
Old 10-27-10, 05:32
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by seanog2001 View Post
I was wondering is it possible to ensure that their cant be duplicate fields on non primary fields?
sure

ALTER TABLE Store
ADD UNIQUE ( Router )
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On