Alter Tables

Various calls to alter Tables in MySQL

To set the auto increment number

ALTER TABLE t2 AUTO_INCREMENT = 101

To rename a table name

ALTER TABLE email_receipt RENAME invoice_settings

To add an index key

ALTER TABLE  `users` ADD INDEX ( `indentifier` ) ;

To add another Column to a table

ALTER TABLE  `users` ADD  `ip` VARCHAR( 15 ) NOT NULL AFTER  `timeout`;

To change the name and type of column

ALTER TABLE  `content` CHANGE  `talk_time`  `talk_time` VARCHAR( 150 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL 

To add a multiple Primary key and foreign key

ALTER TABLE Equipment ADD PRIMARY KEY (EquipmentId, PartnerId), FOREIGN KEY ProductId (ProductId) REFERENCES Product(ProductId);
 
development/sql/alter_tables.txt · Last modified: 2007/09/14 00:22 by vincenzobar
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki