<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    Chapter 6:  MySQL Language Reference 477 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 ALTER TABLE allows you to change the structure of an existing table.  For example, you can add or delete columns, create or destroy indexes, change the type of existing columns, or rename columns or the table itself.   You can also change the comment for the table and type of the table.  See Section 6.5.3 [CREATE TABLE], page 469. If you use ALTER TABLE to change a column speci cation but DESCRIBE tbl_name indicates that your column was not changed, it is possible that MySQL ignored your modi cation for one of the reasons described in  Section 6.5.3.1 [Silent column changes], page 476.  For example, if you try to change a VARCHAR column to CHAR, MySQL will still use VARCHAR if the table contains other variable-length columns. ALTER TABLE  works by making a temporary copy of the original table.   The alteration is performed on the copy, then the original table is deleted and the new one is renamed.  This is done in such a way that all updates are automatically redirected to the new table without any failed updates.  While ALTER TABLE is executing, the original table is readable by other clients.  Updates and writes to the table are stalled until the new table is ready. Note that if you use any other option to  ALTER TABLE  than  RENAME,  MySQL will always create a temporary table, even if the data wouldn't strictly need to be copied (like when you change the name of a column). We plan to x this in the future, but as one doesn't normally do ALTER TABLE that often this isn't that high on our TODO. For MyISAM tables, you can speed up the index recreation part (which is the slowest part of the recreation process) by setting the myisam_sort_buffer_size variable to a high value.    To use ALTER TABLE, you need ALTERINSERT, and CREATE privileges on the table.    IGNORE  is a MySQL extension to ANSI SQL92.  It controls how  ALTER TABLE  works if there are duplicates on unique keys in the new table.  If IGNORE isn't speci ed, the copy is aborted and rolled back.  If IGNORE is speci ed, then for rows with duplicates on a unique key, only the rst row is used; the others are deleted.
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    MERCHANT ACCOUNTS
    DEDICATED SERVERS
    E-COMMERCE HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN
    REGISTRATION
    MANAGE
    YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    Corporate Info
    ABOUT US
    OUR NETWORK
    CONTACT US
    SITE MAP
    Copyright © 2002 Dyntex Group, Inc. All Rights Reserved
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide