Results 1 to 2 of 2

Thread: editing tables

  1. #1
    Join Date
    Jan 2003
    Posts
    15

    Unanswered: editing tables

    quick question-

    how do I add and rename fields on a mySQL table?

    thanks

    Trevor
    Last edited by trevor; 01-09-03 at 23:58.

  2. #2
    Join Date
    Dec 2002
    Location
    Iceland
    Posts
    10
    mysql.com
    ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]

    alter_specification:
    ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
    or ADD [COLUMN] (create_definition, create_definition,...)
    or ADD INDEX [index_name] (index_col_name,...)
    or ADD PRIMARY KEY (index_col_name,...)
    or ADD UNIQUE [index_name] (index_col_name,...)
    or ADD FULLTEXT [index_name] (index_col_name,...)
    or ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
    [reference_definition]
    or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
    or CHANGE [COLUMN] old_col_name create_definition
    [FIRST | AFTER column_name]
    or MODIFY [COLUMN] create_definition [FIRST | AFTER column_name]
    or DROP [COLUMN] col_name
    or DROP PRIMARY KEY
    or DROP INDEX index_name
    or DISABLE KEYS
    or ENABLE KEYS
    or RENAME [TO] new_tbl_name
    or ORDER BY col
    or table_options
    Well here it is, the answear .
    To change type/details fields try this:
    ALTER TABLE table_name MODIFY column_name column_type column_details
    To rename column try this:
    ALTER TABLE table_name CHANGE old_col_name new_column_name column_details
    To add column try this:
    ALTER TABLE table_name ADD new_col_name column_type column_details

    Hope this helps!
    Read more about column types at http://www.mysql.com/doc/en/Column_types.html
    Last edited by server; 01-10-03 at 13:40.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •