Skip to main content

Posts

Showing posts with the label creating tables in mysql

Table Properties

MySQL manages tables using storage engines, each of which handles tables that have a given set of characteristics. Different storage engines have differing performance characteristics, and can be chosen based on which engine most closely matches the char acteristics that are needed. For example, a table may require transactional capabilities and guaranteed data in tegrity even if a crash occurs, or it may require a very fast lookup table stored in memory for which the contents can be lost in a crash and reloaded at the next server startup.  With MySQL, these choices can be made on a per-table basis. Any given table is managed by a particular storage engine. Options can be added to the CREATE TABLE  command in order to control the manner in which the entire table is handled. ENGINE={MyISAM | InnoDB | MEMORY}   Indicates the storage engine to be used for the table  MyISAM is the default storage engine (unless --default-storage-engine has been set) COMMENT='<comme

Creating Database Tables

After the database structure is designed and the database has been created, individual tables can be added. Using accurate assignment of data types and their associated options, tables can be added to the database.   The command syntax is shown below, including the various column and table options;   CREATE TABLE <table> ( <column name> <column type> [<column options>], [<column name> <column type>  [<column options>],…,] [<index list>] )[<table options> ];   Example:   mysql> CREATE TABLE CountryLanguage (          ->  CountryCode CHAR(3) NOT NULL,          ->  Language CHAR(30) NOT NULL,          ->  IsOfficial ENUM('True', 'False') NOT NULL DEFAULT 'False',          ->  Percentage FLOAT(3,1) NOT NULL,          ->  PRIMARY KEY(Country, Language)          ->  )ENGINE = MyISAM COMMENT='Lists Language Spoken';   A line-by-line description of the above  CREATE TABLE st