"Haisam K. Ido" <[EMAIL PROTECTED]> wrote on 01/07/2005 15:04:01:

> 
> I've created the following table (server 4.1 in win2k)
> 
> CREATE TABLE `os` (
>    `id` tinyint(10) NOT NULL auto_increment,
>    `name` varchar(255) NOT NULL default '',
>    `description` varchar(255) default NULL,
>    PRIMARY KEY  (`id`,`name`)
> ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
> 
> and was very surprised that I can do the following twice.  Should'nt 
> this be rejected since name is a primary key ad has already been used?
> 
> INSERT INTO os (name,description) VALUES ( 'winxp','winxp');

No. What you have requested is that the combination of id AND name be 
unique. Since id is auto-increment, every record will be unique unless you 
manually force the id to an old value. I guess you want the values to be 
separately unique, in which case you want
PRIMARY KEY (id), UNIQUE (name) 

        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