Changes

Jump to: navigation, search

Updating and Deleting MySQL Tables

10 bytes removed, 20:03, 29 October 2007
Altering a MySQL Table
== Altering a MySQL Table ==
A pre-existing table in a database may be modified using the SQL ''ALTER TABLE'' statement. The ''ALTER TABLE'' statement allows changes to the structure of a table to be modified. Permitted changes include the addition or removal of columns, changing the data type of a column and renaming of the table or columns.
MySQL typically performs an alteration my copying the table to a temporary table, making changes to the temporary table and then deleting the original table and renaming the temporary table to the replace it.
</pre>
The renaming of a column can be achieved using the ''CHANGE'' keyword together with the old and new column names folloed followed by the current datatype of the column. For example to change a column of type INTEGER named ''customer_id'' to ''new_customer_id'':
<pre>

Navigation menu