Discussion:
Add & Arrange New Column
(too old to reply)
Carlos Mennens
2010-09-17 14:34:02 UTC
Permalink
I have an existing table with a few columns I created a few months
ago. Sadly I left out the column I would like to use for my Primary
Key and wanted to know what is the best way to add a column to an
existing table but also I want the column to appear first before any
other columns since it's the 'id' column and will be set to PRIMARY
KEY NOT NULL.

Thanks for any assistance.

-Carlos
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-***@m.gmane.org
João Cândido de Souza Neto
2010-09-17 14:50:11 UTC
Permalink
alter table "mytable" add id int not null primary key auto_increment first;

I hope it can help you.
--
João Cândido de Souza Neto
Post by Carlos Mennens
I have an existing table with a few columns I created a few months
ago. Sadly I left out the column I would like to use for my Primary
Key and wanted to know what is the best way to add a column to an
existing table but also I want the column to appear first before any
other columns since it's the 'id' column and will be set to PRIMARY
KEY NOT NULL.
Thanks for any assistance.
-Carlos
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-***@m.gmane.org
Loading...