creating two fields that together are UNIQUE
I want to create a table that stores records from different countries. Each record has a six-character identifier (id) that uniquely defines the record whithin ech country specified as two-character country code (country). For example, I can have multiple records in the database with the id='ABCDEF', but they must all have different country code.
Is it posible using mySQL to specify that two fields together form a unique pair,
such as:
CREATE TABLE MyTable (
country CHAR(2) NOT NULL,
id CHAR(6) NOT NULL,
...
UNIQUE(country,id)
);
Or is it other ways to ensure this constraint?
Subject
Views
Written By
Posted
creating two fields that together are UNIQUE
7353
April 22, 2005 07:27AM
8207
April 26, 2005 07:37AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.