索引 理解相关表. foreign key JOIN 与保持参照完整性 关于JOIN 的一些建议,子查询 VS. 联表查询 我发现MySQL 的官方文档里是有教程的. SQL Tutorial - W3Schools The SQL Tutorial for Data Analysis | SQL Tutorial - Mode Analytics Understanding Relational Tables The key here is that having multiple occur…
记文档还是相当重要的! 索引 假名的三个用途 自交(Self Joins) 自然交(Natural Joins) Outer Joins Using Table Aliases Using aliases for column names and calculated fields To shorten the SQL syntax To enable multiple uses of the same table within a single SELECT statement 自交 像下面这…
INDEX Updating Data The IGNORE Keyword Deleting Data Faster Deletes Guidelines for Updating and Deleting Data Updating Data UPDATE customers SET cust_name = 'The Fudds', cust_email = 'elmer@fudd.com' ; To delete a column's value, you can set it to NU…
索引 理解 GROUP BY 过滤数据 vs. 过滤分组 GROUP BY 与 ORDER BY 之不成文的规定 子查询 vs. 联表查询 相关子查询和不相关子查询. 增量构造复杂查询 Always More Than One Solution As explained earlier in this chapter, although the sample code shown here works, it is often not the most efficient way to perf…
之前 manipulate 表里的数据,现在则是 manipulate 表本身. INDEX 创建多列构成的主键 自动增长的规定 查看上一次插入的自增 id 尽量用默认值替代 NULL 外键不可以跨引擎 添加字段与删除字段 & 定义外键 复杂表结构的修改 删除表与修改表名 非常工整的 . .模范脚本: CREATE TABLE customers ( cust_id int NOT NULL AUTO_INCREMENT, cust_name ) NOT NULL , cust_address…
INDEX BAD EXAMPLE Improving Overall Performance Inserting Multiple Rows INSTEAD OF Inserting a Single Row Inserting Retrieved Data BAD EXAMPLE INSERT INTO Customers VALUES(NULL, 'Pep E. LaPew', '100 Main Street', 'Los Angeles', 'CA', ', 'USA', NULL,…
索引 AND. OR 运算顺序 IN Operator VS. OR NOT 在 MySQL 中的表现 LIKE 之注意事项 运用通配符的技巧 Understanding Order of Evaluation 与大多数编程语言一样, AND 比 OR 有更高的优先级. Using Parentheses in WHERE Clauses Whenever you write WHERE clauses that use both AND and OR operators, use parent…
终于结束这本书了,最后两章的内容在官方文档中都有详细介绍,简单过一遍.. 首先是数据备份,最简单直接的就是用 mysql 的内置工具 mysqldump MySQL 8.0 Reference Manual  /  Backup and Recovery  /  Using mysqldump for Backups  /  Dumping Data in SQL Format with mysqldump 导入也巨简单,因为导出文件是 .sql 直接用 source 就 ok 了. 另外,需要…
限制用户的操作权限并不是怕有人恶意搞破坏,而是为了减少失误操作的可能性. 详细文档:https://dev.mysql.com/doc/refman/8.0/en/user-account-management.html 关于用户的信息都存储在 mysql 数据库下的 user 表中,查看所有用户名: mysql> USE mysql; mysql> SELECT user FROM user; +------------------+ | user | +------------------…
InnoDB 支持 transaction ,MyISAM 不支持. 索引: Changing the Default Commit Behavior SAVEPOINT 与 ROLLBACK TO COMMIT 与 ROLLBACK When working with transactions and transaction processing, there are a few keywords that'll keep reappearing. Here are the terms you…