原子DDL
如果 CREATE DATABASE 语句在创建数据库目录之后,但没有提交事务之前失败,数据字典不会感知该数据库的存在。此时,文件系统中的数据库目录需要手动清除。
如果文件系统错误或者异常关闭导致 DROP DATABASE 语句没有成功删除数据库目录,事务并非总会回滚。此时也需要手动干预解决问题。
SQL函数
mysql> SELECT SUM(b'1100'), SUM(DISTINCT b'1100');
+--------------+-----------------------+
| sum(b'1100') | sum(DISTINCT b'1100') |
+--------------+-----------------------+
| 12 | 9 |
+--------------+-----------------------+
SQL语法
SELECT test.dt.a FROM (SELECT 1 AS a) AS dt;
mysql> CREATE VIEW v1 AS SELECT c1, c3 FROM t1;
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE VIEW v1 AS SELECT c2 FROM t1;
ERROR 1050 (42S01): Table 'v1' already exists
mysql> CREATE VIEW IF NOT EXISTS v1 AS SELECT c2 FROM t1;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> SHOW WARNINGS;
+-------+------+---------------------------+
| Level | Code | Message |
+-------+------+---------------------------+
| Note | 1050 | Table 'v1' already exists |
+-------+------+---------------------------+
1 row in set (0.00 sec)
mysql> SHOW CREATE VIEW v1\G
*************************** 1. row ***************************
View: v1
Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`vuser`@`localhost` SQL
SECURITY DEFINER VIEW `v1` AS select `t1`.`c1` AS `c1`,`t1`.`c3` AS `c3` from `t1`
character_set_client: utf8mb4
collation_connection: utf8mb4_0900_ai_ci
1 row in set (0.00 sec)