<< 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 3:  Tutorial Introduction 151 you.  (If you make a poor choice and it turns out later that you need a longer eld, MySQL provides an ALTER TABLE statement.) Animal sex can be represented in a variety of ways, for example, "m" and "f", or perhaps "male" and "female".  It's simplest to use the single characters "m" and "f". The use of the DATE data type for the birth and death columns is a fairly obvious choice. Now that you have created a table, SHOW TABLES should produce some output: mysql> SHOW TABLES; +---------------------+ | Tables in menagerie | +---------------------+ | pet | +---------------------+ To verify that your table was created the way you expected, use a DESCRIBE statement: mysql> DESCRIBE pet; +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | name | varchar(20) | YES   | | NULL | | | owner | varchar(20) | YES   | | NULL | | | species | varchar(20) | YES   | | NULL | | | sex | char(1) | YES   | | NULL | | | birth | date | YES   | | NULL | | | death | date | YES   | | NULL | | +---------+-------------+------+-----+---------+-------+ You can use  DESCRIBE  any time,  for example,  if you forget the names of the columns in your table or what types they are. 3.3.3  Loading Data into a Table After creating your table, you need to populate it.  The LOAD DATA and INSERT statements are useful for this. Suppose your pet records can be described as shown here.  (Observe that MySQL expects dates in YYYY-MM-DD format; this may be di erent from what you are used to.) name owner species    sex  birth death Flu y Harold    cat f 1993-02-04 Claws Gwen cat m    1994-03-17 Bu y Harold    dog f 1989-05-13 Fang Benny    dog m    1990-08-27 Bowser Diane dog m    1998-08-31     1995-07-29 Chirpy Gwen bird f 1998-09-11 Whistler     Gwen bird 1997-12-09 Slim Benny    snake m    1996-04-29 Because you are beginning with an empty table, an easy way to populate it is to create a text le containing a row for each of your animals, then load the contents of the le into the table with a single statement.
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN REGISTRATION
    MANAGE YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    SITE MAP
    Home
    Hosting Plans | Domain Registration | About Us | Contact Us | Site Map
    Terms of Use | Privacy Policy | Guarantees
    Merchant Accounts

    SpiritHost - web hosting for spiritual and education sites
    SpiritHit.com - Religious and Spiritual Portal
  • 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