Create a multiple-column primary key using UNIQUE, if the columns are declared NOT NULL : Primary Key « Key « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
SQL / MySQL » Key » Primary Key 
Create a multiple-column primary key using UNIQUE, if the columns are declared NOT NULL
     
mysql>
mysql> CREATE TABLE people
    -> (
    ->     last_name  CHAR(30NOT NULL,
    ->     first_name CHAR(30NOT NULL,
    ->     UNIQUE (last_name, first_name)
    -> );
Query OK, rows affected (0.00 sec)

mysql>
mysql>
mysql> drop table people;
Query OK, rows affected (0.00 sec)

   
    
    
    
    
  
Related examples in the same category
1.Setting a Primary Key 1
2.Setting a Primary Key 2
3.Setting a Primary Key 3
4.Define and use primary key
5.Alter table to Add an PRIMARY KEY
6.Another way to enforce uniqueness is to add a UNIQUE index rather than a PRIMARY KEY to a table.
7.To drop an index that is not a PRIMARY KEY, you must specify the index name.
8.Adding primary key for not null column
9.Defining Primary Keys
10.Use a PRIMARY KEY constraint
11.If you were creating a primary key on more than one column, you would include both of those column names in th
12.Two ways to declare primary key when creating the table
13.Create a table t that contains an id column that's NOT NULL and declared as a primary key by means of a PRIMAR
14.A primary key on a column can be created by replacing PRIMARY KEY with UNIQUE in the table definition, provide
15.Add PRIMARY KEY or UNIQUE directly to the end of the column definition.
16.Create a primary key on the last_name and first_name columns using a PRIMARY KEY clause
17.Using three column as the primary key
18.Drop primary key
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.