標籤:div des sele back def order span border ack
一、表介紹
表相當於檔案,表中的一條記錄就相當於檔案的一行內容,不同的是,表中的一條記錄有對應的標題,稱為表的欄位
| id |
name |
age |
sex |
| 1 |
MC |
18 |
male |
| 2 |
CW |
20 |
female |
| 3 |
MW |
24 |
male |
id,name,qq,age稱為欄位,其餘的,一行內容稱為一條記錄。列欄位列資料
二、表的建立
#文法:create table 表名(欄位名1 類型[(寬度) 約束條件],欄位名2 類型[(寬度) 約束條件],欄位名3 類型[(寬度) 約束條件]);#注意:1. 在同一張表中,欄位名是不能相同2. 寬度和約束條件可選3. 欄位名和類型是必須的
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, -> name varchar(50), -> 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-表操作