在好例子网,分享、交流、成长!
您当前所在位置:首页SQL 开发实例SQL基础 → MySQL与MariaDB学习指南

MySQL与MariaDB学习指南

SQL基础

下载此实例
  • 开发语言:SQL
  • 实例大小:8.95M
  • 下载次数:11
  • 浏览次数:35
  • 发布时间:2022-07-26
  • 实例类别:SQL基础
  • 发 布 人:夸克
  • 文件格式:.pdf
  • 所需积分:9
 相关标签: MariaDB MySql ADB sql AD

实例介绍

【实例简介】MySQL与MariaDB学习指南

【实例截图】

【核心代码】


目录
序 ............................................................................................................................................................xiii
前言.......................................................................................................................................................xvii
第一部分 软件
第 1 章 入门 .........................................................................................................................................2
1.1 MySQL 和 MariaDB 的价值 ......................................................................................................2
1.2 邮件列表和论坛 .........................................................................................................................3
1.3 其他书籍和出版物 .....................................................................................................................3
第 2 章 安装 MySQL 和 MariaDB .................................................................................................5
2.1 安装包 .........................................................................................................................................5
2.2 许可 .............................................................................................................................................6
2.3 获取软件 .....................................................................................................................................6
2.4 挑选发行版 .................................................................................................................................7
2.5 各种 _AMP .................................................................................................................................8
2.5.1 Linux 二进制发行版 ......................................................................................................8
2.5.2 Mac OS X 发行版 ..........................................................................................................9
2.5.3 Windows 发行版 ..........................................................................................................12
2.5.4 FreeBSD 和 Sun Solaris 发行版 ..................................................................................13
2.5.5 源码包 ..........................................................................................................................15
v2.6 安装后 .......................................................................................................................................16
2.6.1 特殊配置 ......................................................................................................................17
2.6.2 给 root 设置初始密码 ..................................................................................................17
2.6.3 关于密码的更多问题,以及删除匿名用户 .................................................................18
2.6.4 创建用户 ......................................................................................................................19
第 3 章 基础知识与 mysql 客户端 ..............................................................................................20
3.1 mysql 客户端 ............................................................................................................................20
3.2 连接到服务器 ...........................................................................................................................21
3.3 开始探索数据库 .......................................................................................................................23
3.3.1 第一条 SQL 语句 .........................................................................................................24
3.3.2 插入和操作数据 ..........................................................................................................26
3.3.3 再复杂一点 ..................................................................................................................28
3.4 小结 ...........................................................................................................................................29
3.5 习题 ...........................................................................................................................................29
第二部分 数据库结构
第 4 章 创建数据库和表 ................................................................................................................32
4.1 创建数据库 ...............................................................................................................................32
4.2 创建表 .......................................................................................................................................34
4.3 插入数据 ...................................................................................................................................36
4.4 更深入地理解表 .......................................................................................................................37
4.5 小结 ...........................................................................................................................................40
4.6 习题 ...........................................................................................................................................40
第 5 章 更改表 ..................................................................................................................................42
5.1 改表需谨慎 ...............................................................................................................................42
5.2 必修的改表技能 .......................................................................................................................43
5.3 选修的改表技能 .......................................................................................................................51
5.3.1 设置列的默认值 ..........................................................................................................51
5.3.2 设置 AUTO_INCREMENT 的值 .........................................................................................53
5.3.3 改表和建表的另一种方法 ..........................................................................................54
5.3.4 重命名一个表 ..............................................................................................................56
5.3.5 重排序一个表 ..............................................................................................................57
5.4 索引 ...........................................................................................................................................58
vi | 目录5.5 小结 ...........................................................................................................................................62
5.6 习题 ...........................................................................................................................................62
第三部分 数据处理基础
第 6 章 插入数据 ..............................................................................................................................67
6.1 语法 ...........................................................................................................................................67
6.2 实例 ...........................................................................................................................................68
6.2.1 鸟目表 ..........................................................................................................................69
6.2.2 鸟科表 ..........................................................................................................................70
6.2.3 鸟种表 ..........................................................................................................................75
6.3 其他选择 ...................................................................................................................................77
6.3.1 明确插入 ......................................................................................................................77
6.3.2 插入其他表中的数据 ..................................................................................................77
6.3.3 题外话:设置正确的 order_id ..................................................................................79
6.3.4 替换数据 ......................................................................................................................82
6.3.5 数据插入的优先级 ......................................................................................................83
6.4 小结 ...........................................................................................................................................85
6.5 习题 ...........................................................................................................................................86
第 7 章 查询数据 ..............................................................................................................................88
7.1 基本查询 ...................................................................................................................................89
7.2 有条件地查询 ...........................................................................................................................89
7.3 结果排序 ...................................................................................................................................90
7.4 限定结果集 ...............................................................................................................................92
7.5 表连接 .......................................................................................................................................92
7.6 表达式与 LIKE ..........................................................................................................................94
7.7 对结果集进行计数和分组 .......................................................................................................98
7.8 小结 .........................................................................................................................................100
7.9 习题 .........................................................................................................................................100
第 8 章 更新和删除数据 ..............................................................................................................102
8.1 更新数据 .................................................................................................................................102
8.1.1 更新指定行 ................................................................................................................103
8.1.2 按行数更新 ................................................................................................................106
8.1.3 排序后再按行数更新 ................................................................................................107
目录 | vii8.1.4 同时更新多个表 ........................................................................................................108
8.1.5 处理重复 ....................................................................................................................109
8.2 删除数据 .................................................................................................................................111
8.3 小结 .........................................................................................................................................113
8.4 习题 .........................................................................................................................................113
第 9 章 表连接和子查询 ..............................................................................................................115
9.1 合并结果集 .............................................................................................................................115
9.2 表连接 .....................................................................................................................................118
9.2.1 基本的表连接查询 ....................................................................................................119
9.2.2 更新已连接的表 ........................................................................................................123
9.2.3 从已连接的表中删除数据 ........................................................................................124
9.3 子查询 .....................................................................................................................................125
9.3.1 标量子查询 ................................................................................................................126
9.3.2 列子查询 ....................................................................................................................128
9.3.3 行子查询 ....................................................................................................................129
9.3.4 表子查询 ....................................................................................................................130
9.3.5 子查询的性能考虑 ....................................................................................................131
9.4 小结 .........................................................................................................................................131
9.5 习题 .........................................................................................................................................131
第四部分 内置函数
第 10 章 字符串函数 .....................................................................................................................134
10.1 格式化字符串 .......................................................................................................................135
10.1.1 拼接字符串 .............................................................................................................135
10.1.2 设置大小写和引号 .................................................................................................137
10.1.3 修剪和补充字符串 .................................................................................................137
10.2 抽取文本 ...............................................................................................................................139
10.3 搜索字符串及使用长度函数 ...............................................................................................141
10.3.1 在字符串中找出某段子串的位置 .........................................................................141
10.3.2 字符串长度 .............................................................................................................143
10.3.3 比较和查找字符串 .................................................................................................144
10.3.4 在字符串中替换或插入内容 .................................................................................146
10.4 转换字符串类型 ...................................................................................................................148
10.5 压缩字符串 ...........................................................................................................................150
viii | 目录10.6 小结 .......................................................................................................................................151
10.7 习题 .......................................................................................................................................151
第 11 章 日期和时间函数 ............................................................................................................153
11.1 日期和时间的数据类型 .......................................................................................................153
11.2 当前日期和时间 ...................................................................................................................155
11.3 抽取日期和时间中的某部分 ...............................................................................................157
11.4 格式化日期和时间 ...............................................................................................................160
11.5 调整格式标准和时区 ...........................................................................................................162
11.6 日期和时间的加减 ...............................................................................................................164
11.7 比较日期和时间 ...................................................................................................................168
11.8 小结 .......................................................................................................................................171
11.9 习题 .......................................................................................................................................171
第 12 章 聚合函数和数值函数 ...................................................................................................173
12.1 聚合函数 ...............................................................................................................................173
12.1.1 计数 .........................................................................................................................173
12.1.2 对一组数据进行运算 .............................................................................................178
12.1.3 拼接同组的值 .........................................................................................................182
12.2 数值函数 ...............................................................................................................................183
12.2.1 四舍五入 .................................................................................................................183
12.2.2 上舍入或下舍入 .....................................................................................................186
12.2.3 截短数字 .................................................................................................................187
12.2.4 消除负数 .................................................................................................................187
12.3 小结 .......................................................................................................................................189
12.4 习题 .......................................................................................................................................189
第五部分 数据库管理
第 13 章 用户账号和权限 ............................................................................................................192
13.1 用户账号的基础知识 ...........................................................................................................192
13.2 限制用户账号的访问权限 ...................................................................................................194
13.2.1 用户名和主机 .........................................................................................................194
13.2.2 SQL 权限 ................................................................................................................196
13.2.3 数据库组件和权限 .................................................................................................198
13.3 管理员账号 ...........................................................................................................................202
目录 | ix13.3.1 用于备份的用户账号 .............................................................................................202
13.3.2 用于恢复备份的用户账号 .....................................................................................203
13.3.3 用于批量导入的用户账号 .....................................................................................203
13.3.4 用于授权的用户账号 .............................................................................................204
13.4 回收权限 ...............................................................................................................................205
13.5 删除用户账号 .......................................................................................................................206
13.6 更改密码和用户名 ...............................................................................................................207
13.6.1 给用户账号设置密码 .............................................................................................207
13.6.2 用户账号重命名 .....................................................................................................208
13.7 用户角色 ...............................................................................................................................209
13.8 小结 .......................................................................................................................................211
13.9 习题 .......................................................................................................................................211
第 14 章 数据库的备份与恢复 ...................................................................................................213
14.1 备份 .......................................................................................................................................213
14.1.1 备份所有数据库 .....................................................................................................214
14.1.2 理解 dump 文件 ......................................................................................................215
14.1.3 备份指定的数据库 .................................................................................................220
14.1.4 创建备份脚本 .........................................................................................................221
14.1.5 备份指定的表 .........................................................................................................221
14.2 恢复备份 ...............................................................................................................................223
14.2.1 恢复数据库 .............................................................................................................223
14.2.2 恢复表 .....................................................................................................................223
14.2.3 只恢复某些行或列 .................................................................................................228
14.2.4 用二进制日志来做恢复 .........................................................................................229
14.3 制定备份策略 .......................................................................................................................234
14.4 小结 .......................................................................................................................................238
14.5 习题 .......................................................................................................................................238
第 15 章 批量导入数据 ................................................................................................................240
15.1 准备导入 ...............................................................................................................................240
15.2 导入数据的基本做法 ...........................................................................................................243
15.2.1 检查警告信息 .........................................................................................................243
15.2.2 检查导入是否准确 .................................................................................................244
15.2.3 选取导入的数据 .....................................................................................................246
15.3 更好地导入 ...........................................................................................................................248
15.3.1 对应域 .....................................................................................................................248
x | 目录15.3.2 设置列 .....................................................................................................................249
15.4 其他格式的域和行 ...............................................................................................................250
15.4.1 开始、结束和跳脱 .................................................................................................250
15.4.2 替换数据或忽略错误 .............................................................................................251
15.5 在 MySQL 之外导入数据 ....................................................................................................252
15.5.1 导入本地文件 .........................................................................................................253
15.5.2 使用 mysqlimport ...................................................................................................253
15.5.3 没有 FILE 权限也能导入数据 ...............................................................................254
15.6 批量导出数据 .......................................................................................................................254
15.7 小结 .......................................................................................................................................256
15.8 习题 .......................................................................................................................................256
第 16 章 应用编程接口 ................................................................................................................258
16.1 创建 API 用户账号 ..............................................................................................................258
16.2 C API .....................................................................................................................................259
16.2.1 连接 MySQL ...........................................................................................................259
16.2.2 查询 MySQL ...........................................................................................................261
16.2.3 完整的最小 C API 程序 .........................................................................................261
16.2.4 用 GNU C 编译器编译 ...........................................................................................262
16.3 Perl DBI.................................................................................................................................262
16.3.1 安装 .........................................................................................................................263
16.3.2 连接 MySQL ...........................................................................................................263
16.3.3 查询 MySQL ...........................................................................................................263
16.3.4 Perl DBI 完整示例 ..................................................................................................265
16.3.5 更多信息 .................................................................................................................267
16.4 PHP API ................................................................................................................................267
16.4.1 安装与配置 .............................................................................................................267
16.4.2 连接 MySQL ...........................................................................................................268
16.4.3 查询 MySQL ...........................................................................................................268
16.4.4 更多信息 .................................................................................................................271
16.5 Python....................................................................................................................................271
16.5.1 安装 .........................................................................................................................271
16.5.2 连接 MySQL ...........................................................................................................271
16.5.3 查询 MySQL ...........................................................................................................272
16.5.4 Python 程序示例 .....................................................................................................273
16.5.5 更多信息 .................................................................................................................275
16.6 Ruby API ...............................................................................................................................275
目录 | xi16.6.1 安装和准备使用 MySQL/Ruby .............................................................................275
16.6.2 连接 MySQL ...........................................................................................................276
16.6.3 查询 MySQL ...........................................................................................................277
16.6.4 MySQL/Ruby 程序示例 .........................................................................................277
16.6.5 更多信息 .................................................................................................................281
16.7 SQL 注入 ..............................................................................................................................281
16.8 小结 .......................................................................................................................................282
16.9 习题 .......................................................................................................................................282
关于作者 ..............................................................................................................................................284
关于封面 ..............................................................................................................................................284
xii | 目录序


标签: MariaDB MySql ADB sql AD

实例下载地址

MySQL与MariaDB学习指南

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
;
报警