so if I do want 'name' to be unique I must not make it primary, just
simply unique, since my primary key is for id and name simultaneously.
[EMAIL PROTECTED] wrote:
your primary key is based on your (auto-increment) id and the name,
PRIMARY KEY (`id`,`name`)
so your two entries would be:
1,winxp
2,winxp
there's no key conflict/duplication there.
by the way, you do realize what the max range is on the (signed) tinyint
(for your "id"), correct?
------------ Original Message ------------
Date: Friday, July 01, 2005 10:04:01 AM -0400
From: "Haisam K. Ido" <[EMAIL PROTECTED]>
To: mysql@lists.mysql.com
Subject: Primary Key question
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');
--
---------- End Original Message ----------
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]