Moving fields with ALTER TABLE

As is known, called the SQL command ALTER TABLE allows you to manipulate the structure of a table in MySQL. We will see in this very short post as ALTER TABLE can be used to put back a specific field, ie after move Another indicator in education, with Consider the following example:

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;"> ALTER TABLE agenda CHANGE COLUMN cognome cognome VARCHAR(10) AFTER nome;</span> ALTER TABLE CHANGE COLUMN agenda surname surname VARCHAR (10) AFTER name;</span>

In our case, we needed to move the field called “surname” named after the “name”, to do this we passed to the command ALTER TABLE to change the table name (“agenda”), was introduced so the command CHANGE COLUMN followed by the name of the field to modify and its new attributes (the name will remain the same and it will be associated with the data type of VARCHAR length of 10 characters), and finally was introduced AFTER the command after which the specifying the name of the field after which the column will be moved “surname”.

This entry was posted in Database and tagged , , , , . Bookmark the permalink.

Comments are closed.