Hi,
try this and you will see exactly how autoincrement behaves in MyISAM
tables when it is part of primary key.
1) declare table like this:
CREATE TABLE `test_tbl` (
`field1` int(10) unsigned NOT NULL default '0',
`field2` int(10) unsigned NOT NULL auto_increment,
`field3` char(10) NOT NULL default '',
PRIMARY KEY (`field1`,`field2`)
) ENGINE=MyISAM;
2) then insert some values
INSERT INTO test_tbl (field1, field3)
VALUES(1,'test1'),(2,'test2'),(1,'test3'),(2,'test4');
3) see what's in the table
SELECT * FROM test_tbl ORDER BY field1;
result is:
1, 1, 'test1'
1, 2, 'test3'
2, 1, 'test2'
2, 2, 'test4'
field2 is unique only in context of field1.
Hth,
Dusan
Victor Subervi napsal(a):
2010/6/29 João Cândido de Souza Neto <j...@consultorweb.cnt.br>
As far as I know, if you have an auto_increment primary key, you cant have
any other field in its primary key.
Makes sense. Actually, I was just copying what someone else gave me and
adding the auto_increment, then I got to wondering, what is the purpose of
having two primary keys?
TIA,
V
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org