I. Introduction of the Table
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 |
Age |
Sex |
1 |
Mc |
18 |
Male |
2 |
CW |
20 |
Female |
3 |
MW |
24 |
Male |
Id,name,qq,age is called a field, and the rest, a row of content is called a record. row Field column data
Second, the creation of the table
#语法: 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, the field names cannot be the same as 2. Width and constraints are optional 3. The field name and type are required
Mysql> CREATE DATABASE TT character set UTF8; Query OK, 1 row Affected (0.00 sec) mysql> use tt;database changedmysql> CREATE TABLE t1 (id int, n Ame varchar (+), sex enum (' Male ', ' female '), age int (3); Query OK, 0 rows affected (0.10 sec) mysql> show tables;+--------------+| Tables_in_tt |+--------------+| T1 |+--------------+1 row in Set (0.00 sec) mysql> desc 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 | |+-------+-----------------------+------+-----+---------+-------+4 rows in Set (0.01 sec) mysql> Select Id,name,sex , AGe from T1; Empty Set (0.00 sec) mysql> select * from T1; Empty Set (0.00 sec) mysql> Select id,name,sex from T1; Empty Set (0.00 sec)
mysql-table Operation