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

    514 MySQL Technical Reference for Version 4.0.3 7.5.4  Creating InnoDB Tables Suppose  you  have  started  the  MySQL  client  with  the  command  mysql test.   To  create a table in the InnoDB format you must specify TYPE = InnoDB in the table creation SQL command: CREATE TABLE CUSTOMER (A INT, B CHAR (20), INDEX (A)) TYPE = InnoDB; This SQL command will create a table and an index on column A into the InnoDB tablespace consisting of the data les you speci ed in `my.cnf'.  In addition MySQL will create a le `CUSTOMER.frm' to the MySQL database directory `test'.  Internally, InnoDB will add to its own data dictionary an entry for table 'test/CUSTOMER'.  Thus you can create a table of the same name CUSTOMER in another database of MySQL, and the table names will not collide inside InnoDB. You can query the amount of free space in the InnoDB tablespace by issuing the table status command of MySQL for any table you have created with TYPE = InnoDB.  Then the amount of free space in the tablespace appears in the table comment section in the output of SHOW. An example: SHOW TABLE STATUS FROM test LIKE 'CUSTOMER' Note that the statistics  SHOW  gives about InnoDB tables are only approximate:  they are used in SQL optimisation.  Table and index reserved sizes in bytes are accurate, though. 7.5.4.1  Converting MyISAM Tables to InnoDB InnoDB does not have a special optimisation for separate index creation.  Therefore it does not pay to export and import the table and create indexes afterwards.  The fastest way to alter a table to InnoDB is to do the inserts directly to an InnoDB table, that is, use ALTER TABLE ... TYPE=INNODB, or create an empty InnoDB table with identical de nitions and insert the rows with INSERT INTO ... SELECT * FROM .... To get better control over the insertion process, it may be good to insert big tables in pieces: INSERT INTO newtable SELECT * FROM oldtable WHERE yourkey > something AND yourkey <= somethingelse; After all data has been inserted you can rename the tables. During the conversion of big tables you should set the InnoDB bu er pool size big to reduce disk I/O. Not bigger than 80% of the physical memory, though.  You should set InnoDB log les big, and also the log bu er large. Make sure you do not run out of tablespace:  InnoDB tables take a lot more space than MyISAM tables.  If an ALTER TABLE runs out of space, it will start a rollback, and that can take hours if it is disk-bound.  In inserts InnoDB uses the insert bu er to merge secondary index  records  to  indexes  in  batches.   That  saves  a  lot  of  disk  I/O.  In  rollback  no  such mechanism is used, and the rollback can take 30 times longer than the insertion. In the case of a runaway rollback, if you do not have valuable data in your database, it is better that you kill the database process and delete all InnoDB data and log les and all InnoDB table `.frm' les,  and start your job again, rather than wait for millions of disk I/Os to complete.
     

    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