目錄
- MySQL簡(jiǎn)介
- RDBMS的結(jié)構(gòu)與操作思維
- 建立database
- 建立table
- 插入資料
MySQL簡(jiǎn)介
RDBMS的結(jié)構(gòu)與操作思維
![](https://imgur.com/umaeIwu.jpg)
//假設(shè)users為使用者的table,orders為訂單的table select * from users inner join orders on users.id = orders.user_id; |
建立database
show databases; |
create database test; |
use test; |
select database(); |
![](https://imgur.com/3JxlsGi.jpg)
建立table
- 名稱
- 飼主名稱
- 物種
- 出生日期
- 死亡日期
詳情請(qǐng)看這裡 : https://dev.mysql.com/doc/refman/5.6/en/data-types.html
CREATE TABLE pet ( name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); |
![](https://imgur.com/5VJdjvv.jpg)
插入資料
- 使用文件檔案將資料匯入資料庫(kù)
- 使用指令新增資料庫(kù)
欄位名稱 | 值 |
name | coco |
owner | me |
species | dog |
sex | m |
birth | 2018-01-01 |
death | null |
insert into pet ( name,owner,species,sex,birth,death ) values ( 'coco','me','dog','m','2018-01-01',null ); |
values前指定要輸入的值的對(duì)應(yīng)column
select * from pet; |
![](https://imgur.com/a4I2F1H.jpg)
![](https://mpng.subpng.com/20180824/ktx/kisspng-mysql-workbench-computer-icons-logo-portable-netwo-thezedt-tech-tips-and-random-thoughts-5b80352110ca84.1955496015351288650688.jpg)