set names utf8mb4;
set foreign_key_checks =0;
-------table structure for bookcategory
drop
table
ifexists
'bookcategory'
;create
table
'bookcategory'
('category'
varchar(20
)character
set utf8 collect utf8_general_ci not
null
comment
'類別',
primary
key(
'category'
)using
btree
) enging =
innodb
character
set= utf8 collect = utf8_general_ci row_format = compact;
-------table structure for booktable
drop
table
ifexists
'booktable'
;create
table
'booktable'
('bookid'
int(10)
notnull
auto_increment
comment
'書號',
'category'
varchar(20
)character
set utf8 collect utf8_general_ci not
null
comment
'類別',
'bookname'
varchar
(100
)character
set utf8 collect utf8_general_ci not
null
comment
'書名',
'author'
varchar(20
)character
set utf8 collect utf8_general_ci null
default
null
comment
'作者',
'press'
varchar(20
)character
set utf8 collect utf8_general_ci null
default
null
comment
'出版社',
'state'
varchar(20
)character
set utf8 collect utf8_general_ci not
null
comment
'狀態',
primary
key(
'bookid'
)using
btree
,index
'category'
('category'
)using
btree
,constraint
'booktable_ibfk_1'
foreign
key(
'category'
)references
'bookcategory'
('category')on
delete
noaction
onupdate
cascade
)engine
=innodb
auto_increment=19
character
set= utf8 collate
= utf8_general_ci row_format = compact;
------table structure for borrowrecords
drop
table
ifexists
'borrowrecords'
;create
table
'borrowrecords'
('id'
int(10)
notnull
auto_increment
comment
'借書序列'
,'user'
varchar(20
)character
set utf8 collate utf8_general_ci not
null
comment
'使用者名稱'
,'bookid'
int(10)
notnull
comment
'書號'
;'bookname'
varchar(50
)character
set utf8 collate utf8_general_ci not
null
comment
'書名'
,'borrowtime'
date
notnull
comment
'借書時間'
,'returntime'
date
notnull
comment
'還書時間'
,'state'
varchar(20
)character
set utf8 collate utf8_general_ci not
null
comment
'狀態'
,primary
key(
'id'
)using
btree
) enging =
innodb
auto_increment=23
character
set= utf8 collate
= utf8_general_ci row_format = compact;
------table structure for usertable
drop
table
ifexists
'usertable'
;create
table
'usertable'
('user'
varchar(20
)character
set utf8 collate utf8_general_ci not
null
comment
'使用者名稱'
,'studentid'
varchar(20
)character
set utf8 collate utf8_general_ci not
null
comment
'學號'
,'name'
varchar(20
)character
set utf8 collate utf8_general_ci not
null
comment
'姓名'
,'password'
varchar(20
)character
set utf8 collate utf8_general_ci not
null
comment
'密碼'
,'admin'
int(10)
notnull
comment
'是否為管理員賬戶 1為管理員,0為普通使用者,預設為0'
,primary
key(
'user'
)using
btree
)engine
=innodb
character
set= utf8 collate
= utf8_general_ci row_format = compact;
set foreing_key_checks =1;
/*如果指定了character set x和collate y,那麼採用字符集x和校對規則y
b-tree索引是資料庫中訪問和查詢檔案(稱為記錄或鍵值)的一種方法.b-tree演算法減少定位記錄時所經歷的中間過程,從而加快訪問速度.
myisam和innodb儲存引擎只支援btree索引;memory和heap儲存引擎可以支援hash和btree索引
on delete no action on update cascade :
cascade方式 在父表上update/delete記錄時,同步update/delete掉子表的匹配記錄 (級聯刪除)
no action方式 如果子表中有匹配的記錄,則不允許對父表對應候選鍵進行update/delete操作
null default null 預設為null(null與default null都需要)
*/
mysql建立使用者表 mysql 建庫建表建使用者
1.建立資料庫 create database school 2.使用資料庫 use school 3.建立使用者 create user jame localhost identified by jame 4.授權使用者 注意這裡是用了 哦,可以自己講school也替換成 號 grant sele...
mysql建表思路 MySQL 建表思路
思想 硬碟如倉庫,表如倉庫中貨架 常用與不常用等分類 欄位如貨物 尺寸是固定或變動 訪問貨物涉及到貨架的佔位 效率。資料型別選用,建表思路,正規化 資料型別特點 資料型別的速度關係 最快 整形 date,time char,enum varchar text blob 最慢 char 與 varch...
mysql建表建索引6 mysql建表建索引
建表 create table sj projects id int 11 not null auto increment,title varchar 255 not null default comment 專案名稱 platform id int 11 not null default 0 co...