Page 1 of 1

chaneg primary key

Posted: Tue Dec 30, 2003 6:30 am
by lizlazloz
hey, noob here, what is the mysql code to change the priamry key of a table?

Posted: Tue Dec 30, 2003 8:10 am
by McGruff
First, are you sure you want to change a primary key? If you've got several related tables this will break your program.

Check out the [mysql_man]mysql manual[/mysql_man] for info on column types and how to change them.

phpMyAdmin is a popular db tool.

Posted: Wed Dec 31, 2003 8:24 pm
by fractalvibes
Yep, as McGruff said. If this is a brand new table you might be better off just re-creating the table and drop the old. Some RDBMS are really particular on what they allow you to alter, esp. primary key or any columns with indices on them.

fv

Posted: Thu Jan 01, 2004 12:37 am
by JAM

Code: Select all

alter table 'table' drop primary key, add primary key 'field'