news <[EMAIL PROTECTED]> wrote on 06/04/2006 14:39:33:

> IF I have a table like this:
> id int not null,
> field2 int not null,
> ......,
> primary key (id),
> key (field2)
> ) ENGINE=MyISAM;
> 
> The primary key is id only or (id, field2)?
> If this is the case which constraint are aplied on field2? 

You have defined two separate keys, one on ID and one on field2. The id 
field, being primary, must be without nulls and each entry must be unique. 
The key on field2, not being a primary key, may contain duplicates and 
nulls.

Are you searching for the synax ... primary key keyname (id, field2) ... ? 
This creates a single key in which neither of the fields may be null and 
the combination of the two fields (but not the two fields separately) must 
be unique.

The effects on the two formulations both on constraints and on search 
performance are different.

        Alec





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to