MySQL 數據庫入門, 2/e
黑馬程序員
買這商品的人也買了...
-
$580$522 -
$580$493 -
$500$450 -
$520$510 -
$450$356 -
$400$340 -
$240$228 -
$305JavaScript + jQuery 交互式 Web 前端開發
-
$177MySQL 數據庫原理、設計與應用
-
$356算法實例精講——Python語言實現
-
$580$568 -
$500Android App 開發入門與項目實戰
-
$454OpenCV 4.5 電腦視覺開發實戰 (基於 VC++)
-
$594$564 -
$301軟件項目開發實戰 — App 全棧
-
$760$593 -
$680$537 -
$790$616 -
$306MySQL 實用教程, 4/e
相關主題
商品描述
本書是一本面向MySQL數據庫初學者推出的入門教材,全書以通俗易懂的語言、豐富實用的案 例,詳細講解了MySQL數據庫技術的相關知識。 全書共10章,第1~5章主要講解MySQL中的基礎操作,包括數據庫入門知識、MySQL的安裝與 配置、數據庫和數據表的基本操作、單表查詢以及多表操作;第6~9章圍繞數據庫開發的一些高級 知識展開講解,包括索引、視圖、事務、數據庫編程、數據庫的管理和維護;第10章通過一個簡單 的Java Web項目講解MySQL在項目中的應用。 本書配有教學大綱、教學設計、源代碼、習題等資源,而且為了幫助初學者更好地學習本教材 中的內容,還提供了在線答疑,希望得到更多讀者的關註。 本書既可作為高等院校本、專科電腦相關專業的數據庫開發與管理教材,也可作為數據庫開 發基礎的培訓教材,是一本適合廣大電腦編程愛好者的優秀讀物。
目錄大綱
目
錄
第1章
數據庫入門
.
...............................................1
1.1 數據管理技術的發展 .................................1
1.2 數據庫技術的基本術語 .............................3
1.3 數據模型 .....................................................4
1.3.1 初識數據模型 .................................4
1.3.2 E-R圖 ...............................................6
1.3.3 關系模型 .........................................7
1.4 常見的數據庫產品 ...................................10
1.5 SQL簡介 ....................................................11
1.6 MySQL安裝與配置 ..................................12
1.6.1 獲取MySQL ..................................12
1.6.2 安裝MySQL ..................................15
1.6.3 配置MySQL ..................................17
1.6.4 管理MySQL服務 ..........................18
1.6.5 登錄MySQL與密碼設置 ..............19
1.6.6 配置環境變量 ...............................23
1.7 常用圖形化管理工具 ...............................24
1.7.1 SQLyog ..........................................25
1.7.2 Navicat ...........................................26
1.8 上機實踐:圖書管理系統的E-R圖
設計 ...........................................................28
1.9 本章小結 ...................................................31
1.10 課後習題 .................................................31
第2章
數據庫和數據表的基本操作.................33
2.1 數據庫的基本操作 ...................................33
2.1.1 創建數據庫 ...................................33
2.1.2 查看數據庫 ...................................35
2.1.3 選擇數據庫 ...................................37
2.1.4 修改數據庫特徵 ...........................37
MySQL數據庫入門(第2版)
IV
2.1.5 刪除數據庫 ..................................................................................................38
2.2 數據類型 ..................................................................................................................39
2.2.1 數值類型 ......................................................................................................39
2.2.2 日期和時間類型 ..........................................................................................41
2.2.3 字符串類型 ..................................................................................................43
2.3 數據表的基本操作 ..................................................................................................46
2.3.1 創建數據表 ..................................................................................................46
2.3.2 查看數據表 ..................................................................................................47
2.3.3 修改數據表 ..................................................................................................50
2.3.4 刪除數據表 ..................................................................................................57
2.4 表的約束 ..................................................................................................................58
2.4.1 非空約束 ......................................................................................................58
2.4.2 唯一約束 ......................................................................................................61
2.4.3 主鍵約束 ......................................................................................................64
2.4.4 默認值約束 ..................................................................................................67
2.5 自動增長 ..................................................................................................................70
2.6 上機實踐:圖書管理系統的數據庫及相關數據表的創建 .................................71
2.7 本章小結 ..................................................................................................................74
2.8 課後習題 ..................................................................................................................74
第3章 數據操作.....................................................................................................................76
3.1 插入數據 ..................................................................................................................76
3.1.1 一次插入單條數據 ......................................................................................76
3.1.2 一次插入多條數據 ......................................................................................81
3.2 更新數據 ..................................................................................................................83
3.3 刪除數據 ..................................................................................................................86
3.4 上機實踐:圖書表的數據操作 .............................................................................92
3.5 本章小結 ..................................................................................................................95
3.6 課後習題 ..................................................................................................................95
第4章
單表查詢.....................................................................................................................97
4.1 SELECT語句 ............................................................................................................98
4.2 簡單查詢 ..................................................................................................................82
4.2.1 查詢所有字段 ..............................................................................................82
4.2.2 查詢指定字段 ............................................................................................101
4.2.3 查詢去重數據 ............................................................................................102
4.3 條件查詢 ................................................................................................................104
目
錄
V
4.3.1 帶比較運算符的查詢 ................................................................................104
4.3.2 帶邏輯運算符的查詢 ................................................................................110
4.4 高級查詢 ................................................................................................................114
4.4.1 聚合函數 ....................................................................................................114
4.4.2 分組查詢 ....................................................................................................118
4.4.3 排序查詢 ....................................................................................................119
4.4.4 限量查詢 ....................................................................................................121
4.4.5 內置函數 ....................................................................................................123
4.5 設置別名 ................................................................................................................126
4.5.1 為數據表設置別名 ....................................................................................126
4.5.2 為字段設置別名 ........................................................................................127
4.6 上機實踐:圖書管理系統的單表查詢 ...............................................................128
4.7 本章小結 ................................................................................................................131
4.8 課後習題 ................................................................................................................131
第5章
多表操作...................................................................................................................133
5.1 多表查詢 ................................................................................................................133
5.1.1 交叉連接查詢 ............................................................................................133
5.1.2 內連接查詢 ................................................................................................135
5.1.3 外連接查詢 ................................................................................................136
5.1.4 復合條件連接查詢 ....................................................................................138
5.2 子查詢 ....................................................................................................................139
5.2.1 IN關鍵字結合子查詢 ................................................................................139
5.2.2 EXISTS關鍵字結合子查詢 .......................................................................140
5.2.3 ANY關鍵字結合子查詢 ............................................................................141
5.2.4 ALL關鍵字結合子查詢 .............................................................................142
5.2.5 比較運算符結合子查詢 ............................................................................142
5.3 外鍵約束 ................................................................................................................143
5.3.1 添加外鍵約束 ............................................................................................143
5.3.2 操作關聯表 ................................................................................................145
5.3.3 刪除外鍵約束 ............................................................................................148
5.4 上機實踐:圖書管理系統的多表操作 ...............................................................149
5.5 本章小結 ................................................................................................................151
5.6 課後習題 ................................................................................................................152
第6章
索引和視圖...............................................................................................................154
6.1 索引 ........................................................................................................................154
6.1.1 索引概述 ....................................................................................................155
6.1.2 索引的創建 ................................................................................................156
6.1.3 索引的查看 ................................................................................................162
6.1.4 索引的刪除 ................................................................................................165
6.2 視圖 ........................................................................................................................167
6.2.1 視圖概述 ....................................................................................................168
6.2.2 視圖管理 ....................................................................................................168
6.2.3 視圖數據操作 ............................................................................................178
6.3 上機實踐:圖書管理系統中索引和視圖的應用 ...............................................180
6.4 本章小結 ................................................................................................................182
6.5 課後習題 ................................................................................................................182
第7章
事務...........................................................................................................................184
7.1 事務處理 ................................................................................................................184
7.1.1 事務概述 ....................................................................................................184
7.1.2 事務的基本操作 ........................................................................................185
7.1.3 事務的保存點 ............................................................................................188
7.2 事務的隔離級別 ....................................................................................................191
7.2.1 READ UNCOMMITTED...........................................................................191
7.2.2 READ COMMITTED ................................................................................195
7.2.3 REPEATABLE READ ................................................................................197
7.2.4 SERIALIZABLE ........................................................................................200
7.3 上機實踐:圖書管理系統中事務的應用 ...........................................................201
7.4 本章小結 ................................................................................................................203
7.5 課後習題 ................................................................................................................203
第8章
數據庫編程...............................................................................................................205
8.1 存儲過程 ................................................................................................................205
8.1.1 創建存儲過程 ............................................................................................206
8.1.2 查看存儲過程 ............................................................................................207
8.1.3 調用存儲過程 ............................................................................................209
8.1.4 修改存儲過程 ............................................................................................209
8.1.5 刪除存儲過程 ............................................................................................211
8.2 存儲函數 ................................................................................................................211
8.2.1 創建存儲函數 ............................................................................................211
8.2.2 查看存儲函數 ............................................................................................213
8.2.3 調用存儲函數 ............................................................................................214
8.2.4 刪除存儲函數 ............................................................................................215
8.3 變量 ........................................................................................................................215
8.3.1 系統變量 ....................................................................................................215
8.3.2 用戶變量 ....................................................................................................218
8.3.3 局部變量 ....................................................................................................219
8.4 流程控制 ................................................................................................................220
8.4.1 判斷語句 ....................................................................................................220
8.4.2 循環語句 ....................................................................................................223
8.4.3 跳轉語句 ....................................................................................................227
8.5 錯誤處理 ................................................................................................................228
8.5.1 自定義錯誤名稱 ........................................................................................228
8.5.2 自定義錯誤處理程序 ................................................................................229
8.6 游標 ........................................................................................................................231
8.6.1 游標的操作流程 ........................................................................................231
8.6.2 使用游標檢索數據 ....................................................................................232
8.7 觸發器 ....................................................................................................................235
8.7.1 觸發器概述 ................................................................................................235
8.7.2 觸發器的基本操作 ....................................................................................235
8.8 上機實踐:數據庫編程實戰 ...............................................................................240
8.9 本章小結 ................................................................................................................245
8.10 課後習題 ..............................................................................................................246
第9章
數據庫的管理和維護...............................................................................................247
9.1 數據備份與還原 ....................................................................................................247
9.1.1 數據的備份 ................................................................................................247
9.1.2 數據的還原 ................................................................................................250
9.2 用戶管理 ................................................................................................................253
9.2.1 user表 ..........................................................................................................253
9.2.2 創建用戶 ....................................................................................................256
9.2.3 刪除用戶 ....................................................................................................258
9.2.4 修改用戶密碼 ............................................................................................259
9.3 權限管理 ................................................................................................................263
9.3.1 MySQL的權限 ...........................................................................................263
9.3.2 授予權限 ....................................................................................................265
9.3.3 查看權限 ....................................................................................................266
9.3.4 收回權限 ....................................................................................................267
9.4 上機實踐:圖書管理系統數據庫的管理 ...........................................................268
9.5 本章小結 ................................................................................................................269
9.6 課後習題 ................................................................................................................269
第10章
綜合開發案例—圖書借閱系統.............................................................................271
10.1 系統分析 ..............................................................................................................271
10.1.1 系統功能需求 ........................................................................................271
10.1.2 系統功能結構 ........................................................................................272
10.1.3 系統預覽 ................................................................................................272
10.2 數據庫設計 ..........................................................................................................274
10.2.1 實體設計 ................................................................................................274
10.2.2 E-R圖設計 ..............................................................................................276
10.2.3 數據庫邏輯結構設計 ............................................................................276
10.3 系統開發準備 ......................................................................................................277
10.3.1 預備知識 ................................................................................................278
10.3.2 開發環境搭建 ........................................................................................280
10.4 用戶登錄模塊開發 ..............................................................................................282
10.4.1 用戶登錄 ................................................................................................282
10.4.2 註銷登錄 ................................................................................................285
10.5 新書推薦模塊開發 ..............................................................................................287
10.5.1 查詢新書 ................................................................................................287
10.5.2 借閱新書 ................................................................................................291
10.6 圖書借閱模塊開發 ..............................................................................................297
10.6.1 查詢圖書 ................................................................................................297
10.6.2 新增圖書 ................................................................................................303
10.6.3 編輯圖書 ................................................................................................306
10.7 當前借閱模塊開發 ..............................................................................................308
10.7.1 查詢當前借閱 ........................................................................................308
10.7.2 歸還圖書 ................................................................................................313
10.7.3 歸還確認 ................................................................................................316
10.8 借閱記錄模塊開發 ..............................................................................................320
10.8.1 新增借閱記錄 ........................................................................................320
10.8.2 查詢借閱記錄 ........................................................................................323
10.9 本章小結 ..............................................................................................................329