Mysql and multiple auto_increment columns.

From: Matthew Schumacher <schu@schu.net>
Date: Fri Sep 22 2006 - 18:20:46 AKDT

Okay, I'm sure you have all heard my rants about how much better
postgres is than mysql, but now I find myself in a situation where I
need to host something with a provider that doesn't support postgres.
So I go to convert my app to mysql and find that I can't use more than
one auto_increment column in a table:

mysql> CREATE TABLE test_tab (
    -> id serial NOT NULL,
    -> sortid serial NOT NULL
    -> );
ERROR 1075 (42000): Incorrect table definition; there can be only one
auto column and it must be defined as a key

Someone please tell me I'm doing something wrong and can fix this in the
database!! I really need two auto_increment columns, and no I don't want
to do the max(id) + 1 hack because that would require me to change a
bunch of queries for something the database should do.

Can I create a sequence and make the column default
nextval('menu_tab_menuid_seq')?

Perhaps a procedure? Something?

Thanks,
schu
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Sep 22 18:21:14 2006

This archive was generated by hypermail 2.1.8 : Fri Sep 22 2006 - 18:21:14 AKDT