Edit Article

Edited by Maluniu, Michal, omniomi, Harri and 3 others

Here is a summary of the query to make changes to MySQL database structure tables.

EditSteps

  1. 1
    Use the command: ALTER TABLE <tablename> <change-command> ;

    Make Changes to the Database Structure in MySQL Step 1.jpg
  2. Make Changes to the Database Structure in MySQL Step 2.jpg
    2
    Check the results: SELECT * FROM <tablename> ;


Add your own method
Save

EditTips

  • 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>

Article Info

Categories: Stub | MySQL

Recent edits by: Jeff, Aakash Raj Dahal, Harri

Thanks to all authors for creating a page that has been read 4,029 times.

Was this article accurate?

YesNo