Alter Table In Database

To alter a table, right click on a table in the Object Browser and select the menu option Alter Table from the popup menu, or go to (Table -> Alter Table) from the menu bar (or press F6 if you have focus on that table in the Object Browser). This opens up a tab similar to the create table tab with the column names and values already filled up, as shown below. From here, edit the column value(s), add new column(s), delete existing column(s) etc.

If the table contains data rows, some data may be affected due to changes (i.e. if data type is changed or length is reduced). If the change is not permitted (e.g. you specify a column as primary key which contains NULL values), an error message is triggered and the specific offending change is not effected.

If the data entered is incorrect, you can cancel the changes by clicking the Revert button. Click on Save to alter the table. If you want to see the ALTER TABLE SQL-statement that SQLyog sends to the server before executing it, click on the Preview tab.