Read Catalogue
- Introduction to a storage engine
- Two table Introduction
- Three Create a table
- Four view table structure
- Five data types
- Six-table integrity constraints
- Seven Modified tables ALTER TABLE
- Eight copy table
- Nine Delete a table
Introduction to a storage engine
The storage engine is a table type, and MySQL has different processing mechanisms depending on the table type
See: http://www.cnblogs.com/llhtjwq/p/8306708.html
Two table Introduction
Table is equivalent to a file, a record in the table is equivalent to a row of the file, but a record in the table has a corresponding title, called the table field
Id,name,qq,age is called a field, the rest, a row of content is called a record
Three Create a table
# Syntax: CREATE TABLE table name (field name 1 type [(width) constraint], field name 2 Type [(width) constraint], field name 3 Type [(width) constraint]); # Note:1. In the same table, field names cannot be the same as 2. Width and constraints optional 3. Field names and types are required
View Codeinserting data into a table
Note Note: Do not add commas to the last field in the table
Four view table structure
MariaDB [db1]> describe T1; # +-------+-----------------------+------+-----+---------+-- -----+| Field | Type | Null | Key | Default | Extra |+-------+-----------------------+------+-----+---------+-------+| ID | Int (11) | YES | | NULL | || name | varchar (50) | YES | | NULL | || sex | Enum ( " male , " female ") | YES | | NULL | || Age | Int (3) | YES | | NULL | |+-------+-----------------------+------+-----+---------+-------+ MariaDB [DB1] > Show CREATE TABLE T1\g; #
Five data types
Http://www.cnblogs.com/llhtjwq/p/8306716.html
Six-table integrity constraints
Http://www.cnblogs.com/llhtjwq/p/8306721.html
Seven Modified tables ALTER TABLE
syntax:1. Modify the table name alter the table name RENAME a new table name; 2. Add field ALTER table name add field name data type [integrity constraint ...], add field name data type [integrity constraint ...]; ALTER Table name ADD field name data type [integrity constraint ...] First; ALTER Table Table name ADD field name data type [integrity constraint ...] After field name; 3. Delete field ALTER table name drop field name; 4. Modify field ALTER TABLE name MODIFY field name data type [integrity constraint ...]; ALTER Table table name change old field name new field name old data type [integrity constraint condition ...]; ALTER table name change old field name new data type [integrity constraint ...];
Example
Eight copy table
Copy table structure + record (key does not replicate: primary key, foreign key, and index) MySQL from Service; Copy table structure only MySQL from service where 1=2; condition is false, no record is found for empty set (0.00 sec) MySQL from service where 1=2; Query OK, 0 rows affected (0.00 sec) records:0 duplicates:0 warnings:0mysql> CREATE TABLE t 4 like employees;
Nine Delete a table
DROP table name;
MySQL III: Table operations