bruce wrote:
hi..

i have a table that i want to add a column to, and define the columm to be
the primary key. however, i already have a column in the table that's used
as the primary. can someone tell me the approach/commands i should use to
get my results?

table foo
username varchar(50), primary

what i want...
userid int(), primary
username varchar(50)


http://dev.mysql.com/doc/mysql/en/alter-table.html

I would try this :
-- drop the PK
ALTER TABLE foo DROP PRIMARY KEY;
-- add the new one
ALTER TABLE foo ADD userid integer unsigned NOT NULL auto_increment, ADD PRIMARY KEY(userid);
-- move it to the first column
ALTER TABLE foo MODIFY userid integer unsigned NOT NULL auto_increment BEFORE username;

[Note,
ALTER TABLE foo ADD userid integer unsigned NOT NULL auto_increment BEFORE username, ADD PRIMARY KEY(userid);
does not seems to work, possibly a bug ?
]



with userid listed before username!!
can someone tell me what the commands are that i need to enter to get this!!

i thought something like,
alter table foo add userid int(8), primary first (but i couldn't get it to
work.. errors)
and then i couldn't see how to remove the primary key fom username...

thanks

-bruce
[EMAIL PROTECTED]





--
Philippe Poelvoorde
COS Trading Ltd.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to