How to Make Changes to the Database Structure in Mysql
Here is a summary of the query to make changes to MySQL database structure tables.
[edit] Steps
- Use the command: ALTER TABLE <tablename> <change-command> ;
- Check the results: SHOW COLUMNS FROM <tablename> ;
[edit] Tips
- Here is a list of the <change-command> you can use:
- Add new column: ADD <columname> <datatype> <optional-parameters>
- Change default value for a column: ALTER <columnname> SET DEFAULT <newvalue>
- Remove default value for a column: ALTER <columnname> DROP DEFAULT
- Change the definition of a column and rename the column: CHANGE <columnname> <newcolname> <datatype> <optional-parameters>
- Change the definition of a column: MODIFY <columnname> <datatype> <optional-parameters>
- Delete a column (and all data permanently): DROP <columnname>
- Rename a table: RENAME <newtablename>










