MYSQL 建立資料表

2021-07-15 05:48:12 字數 1572 閱讀 1426

rdbms即關聯式資料庫管理系統(relational database management system)的特點:

rdbms術語

資料庫:一些關聯的表的集合

資料表:資料的矩陣。等同於簡單的電子**

列:同一類資料

行:一組相關資料,稱為乙個記錄

冗餘:儲存量被資料,使系統速度更快。

主鍵:唯一。

外來鍵:關聯兩個表

復合鍵:將多個列作為索引鍵

索引:快速訪問資料庫中的特殊資訊。索引是對資料庫表中一列或多了的值進行排序的一種結構

參照完整性:參照中不允許使用不存在的實體。意識體完整性是關係模型必須滿足的完整性約束條件。

>建立資料表

# 注釋內容(與python很像)

-- 也為注釋內容

-- 建立乙個資料庫

create database if not exists maizi default character set 'utf8';

use maizi;

set names gbk;

--建立資料表(user)

--編號id

--使用者名稱usename

--性別***

--郵箱email

--位址addr

--生日birth

--薪水salary

--**tel

--是否結婚married

--當需要中文的時候,需要臨時轉換客戶端的編碼方式

--set names gbk;

--欄位注釋,通過comment注釋內容給字段新增注釋。

create table if not exists first_table(

id smallint,

usename tinyint,

age tinyint,

email varchar(50),

addr varchar(200),

birth year,

salary float(8,2),

tel int,

married tinyint(1) comment '0代表未結婚,非零代表結婚'

)engine=innodb charset=utf8;

show tables;

--建立乙個課程表course

--編號cid

--課程名稱 coursename

--課程描述 coursedesc

create table if not exists course(

cid tinyint,

coursename varchar(50),

coursedesc varchar(200)

);show tables;

--作業

--建立新聞類表

--建立新聞表

新增幾個函式

show tables; #顯示資料庫中的表

檢視表的結構:

desc tbl_name

describe tbl_name

show columns from tbl_name

建立mysql資料表

mysql建表語句 create table if not exists db name.table name colunum1 date not null comment 列欄位說明 colunum2 int 11 not null comment 列欄位說明 colunum3 int 11 no...

MySQL 建立資料表

建立mysql資料表需要以下資訊 以下為建立mysql資料表的sql通用語法 create table table name column name column type 以下例子將在 runoob 資料庫中建立資料表runoob tbl runoob tbl runoob id int not ...

MySQL 建立資料表

mysql 建立資料表 建立mysql資料表需要以下資訊 1.表名 2.表欄位名 3.定義每個表字段 語法 以下為建立mysql資料表的sql通用語法 create table 表名 列定義 其中 1.表名 最多可有128個字元,如s,sc,c等,不允許重名 2.列定義 的書寫格式為,列名 資料型別...