MySQL-表操作

來源:互聯網
上載者:User

標籤: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-表操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.