MySql: Drop table, rename table, drop foreign key, drop column
July 24th, 2009 by jeremychone
#switch to the right DB
USE database_name;
#drop a table
DROP TABLE table_name;
#rename a table
RENAME TABLE table_name TO new_table_name;
#drop a foreign key
ALTER TABLE table_name DROP FOREIGN KEY FK_name;
#drop a column
ALTER TABLE table_name DROP COLUMN column_name;
#change a column to varchar(128)
ALTER TABLE table_name CHANGE column_oldName column_newName varchar(128)
See MySQL Alter Table doc.
# Check the foreign key of a particular database
SELECT * FROM information_schema.KEY_COLUMN_USAGE where TABLE_SCHEMA='myDatabaseName';
Source
Posted:
Friday, July 24th, 2009
Tags: Mysql.
Actions: RSS 2.0 feed.
You can leave a response, or trackback from your own site.