i3m digital media studio archive blog articles i3m digital media studio archive blog articles i3m digital media studio last ten postings to the blog
  • One of 47 entries in the i3m blog (46 before this & 0 since).
  • MySQL table manipulation

  • August 20, 2009, 12:59 pm
  •  
  • Every command in one place...


  • All you ever need to remember about MySQL table manipulation in one easy place to find it!


    Rename an existing table:

    mysql> ALTER TABLE tableName RENAME newName;


    Changing the dataype for an existing column:

    mysql>ALTER TABLE tableName MODIFY columnName;


    Adding a column to an existing table:

    mysql> ALTER TABLE tableName ADD columnName columnType;


    Removing a column from an existing table:

    mysql> ALTER TABLE tableName DROP columnName;


    After a table edit it is good practice to optimise the table in order for it to run as efficiently as possible. The MySQL OPTIMIZE command orchestrates this but will not stop access to the table while running (It will suspend writing to the table until complete though).
    mysql>OPTIMIZE TABLE tableName;


    Completely removing a MySQL table:

    mysql> DROP TABLE tableName;

  • Ever forgotten that MySQL syntax when manipulating table? Look no further.....
    quotation mark
  • Posted in: Programming | comments: off | filters: off
  • subscribe to the i3m rss feed subscribe | Bookmark and Share
  • back to top