數值
拓展:阿里巴巴開發手冊
/*每乙個表,都必須存在以下五個字段!表示乙個記錄存在的意義,
必須要這五個欄位來判斷它,來保證它的乙個健壯性和安全性。
id 主鍵,自增的
`version`
樂觀鎖is_delete 偽刪除,用了乙個標誌位判斷,就設為1,就認為刪除了,但在資料庫中還存在,方便管理員檢視被刪除的資訊
gmt_create 建立時間,記錄的建立時間
gmt_update 修改時間,記錄的修改時間
*/
建立學生表(列,字段) 使用sql 建立
學號int 登入密碼varchar(20) 姓名,性別varchar(2),出生日期(datatime),家庭住址,email
注意點: 使用英文(),表的名稱 和 字段 盡使用 `` 括起來
auto_increment
字串使用 單引號括起來
所有的語句後面加 , (英文的),最後乙個不用加
primary key 主鍵,一般乙個表只有乙個唯一的主鍵!
create
table
ifnot
exists
`student`
(`id`
int(4)
notnull
auto_increment
comment
'學號'
,`name`
varchar(30
)not
null
default
'匿名'
comment
'姓名'
,`pwd`
varchar(20
)not
null
default
'123456'
comment
'密碼'
,`***`
varchar(2
)not
null
default
'女'comment
'性別'
,`birthday`
datetime
default
null
comment
'出生日期'
,`address`
varchar
(100
)default
null
comment
'家庭住址'
,`email`
varchar(50
)default
null
comment
'郵箱'
,primary
key(
`id`))
engine
=innodb
default
charset
=utf8 ;
格式:,裡面的內容是可選,可寫可不寫
create table [if not exists]表名
(
『欄位名』 列型別 [屬性] [索引] [注釋],
『欄位名』 列型別 [屬性] [索引] [注釋],
…『欄位名』 列型別 [屬性] [索引] [注釋]9.建立資料庫表.note
)[表型別][字符集設定] [注釋]
三個逆向檢視sql語句:
show
create
database school -- 檢視建立資料庫的語句
show
create
table student -- 檢視student資料表的定義語句
desc student -- 顯示表的結構
MySQL資料表型別 資料型別
表型別 mysql的資料表型別很多,其中比較重要的是myisam,innodb這兩種。這兩種型別各有優缺點,需要根據實際情況選擇適合的,mysql支援對不同的表設定不同的型別。下面做個對比 myisam表型別是一種比較成熟穩定的表型別,但是myisam對一些功能不支援。myisam innodb 事...
MySQL資料型別和運算元據表
tinyint 1位元組 有符號值 128到127 2 7 到 2 7 1 無符號值 0 到 255 0 到 2 8 1 smallint 2位元組 有符號值 3278 到 32767 2 15 到 2 15 1 無符號值 0 到 65535 0 到 2 16 1 mediumint 3位元組 有符...
mysql資料型別總結表
1 整型 mysql資料型別 含義 有符號 tinyint m 1個位元組 範圍 128 127 smallint m 2個位元組 範圍 32768 32767 mediumint m 3個位元組 範圍 8388608 8388607 int m 4個位元組 範圍 2147483648 214748...