[plug] auto-increment in mysql
Jon Miller
jlmiller at mmtnetworks.com.au
Wed Jan 1 22:06:40 WST 2003
Seems the only way is to create a new table with the columns in the
correct order and then copy the data from the old table to the new
table. Is there a better/quicker way?
Thx
On Wed, 2003-01-01 at 22:02, Jon Miller wrote:
> Thanks for that just one more question is there a way to make the new
> column the first column?
>
> Jlm
>
> On Wed, 2003-01-01 at 21:46, James Bromberger wrote:
> > Craig Ringer (craig at postnewspapers.com.au) wrote:
> > > ALTER TABLE tablename ADD COLUMN colname TYPENAME AUTO_INCREMENT;
> > >
> > > thats the general idea, anyway. I mainly use postgresql these days so I
> > > may be a bit rusty. Hmm... when I tried it the db said:
> > >
> > > mysql> ALTER TABLE test ADD COLUMN testing int AUTO_INCREMENT;
> > > ERROR 1075: Incorrect table definition; There can only be one auto
> > > column and it must be defined as a key
> >
> >
> > mysql> ALTER TABLE test ADD COLUMN testing int PRIMARY KEY AUTO_INCREMENT;
> >
> >
> > But "there can be only one"... primary key per table (hence the name
> > 'primary', and thus there can be only one auto_increment). ut I am sure
> > that mysql 4 is a whole new world, just bursting to get out of
> > Debian/experimental into debian/unstable.... at some time...
> >
> >
> > JB
> >
> > PS: All you PLUGers and lurkers who are thinking about registering for
> > LCA; hurry up and DO IT! It's only 2 and a bit weeks away! Hurry up!
> > http://www.linux.conf.au/
--
Jon Miller <jlmiller at mmtnetworks.com.au>
MMT Networks Pty Ltd
More information about the plug
mailing list