DRDS SQL兼容性
SQL 兼容性
更新时间:2017-06-07 13:26:11
DRDS 高度兼容 MySQL 协议和语法,但由于分布式数据库和单机数据库存在较大的架构差异,存在 SQL 使用限制。相关兼容性和 SQL 限制描述如下。
DRDS SQL 限制
SQL 大类限制
- 暂不支持用户自定义数据类型、自定义函数。
- 暂不支持视图、存储过程、触发器、游标。
- 暂不支持 BEGIN…END、LOOP…END LOOP、REPEAT…UNTIL…END REPEAT、WHILE…DO…END WHILE 等复合语句。
- 暂不支类似 IF ,WHILE 等流程控制类语句。
小语法限制
DDL
- CREATE TABLE tbl_name LIKE old_tbl_name 不支持拆分表。
- CREATE TABLE tbl_name SELECT statement 不支持拆分表。
DML
- 暂不支持 SELECT INTO OUTFILE/INTO DUMPFILE/INTO var_name。
- 暂不支持 INSERT DELAYED Syntax。
- 暂不支持非 WHERE 条件的 Correlate Subquery。
- 暂不支持 SQL 中带聚合条件的 Correlate Subquery。
- 暂不支持 SQL 中对于变量的引用和操作,比如 SET @c=1, @d=@c+1; SELECT @c, @d。
数据库管理
- SHOW WARNINGS Syntax 不支持 LIMIT/COUNT 的组合。
- SHOW ERRORS Syntax 不支持 LIMIT/COUNT 的组合。
DRDS SQL 兼容
协议兼容
DRDS 支持 MySQL Workbench , Navicat For MySQL , SQLyog 等主流客户端。
DDL 语法兼容
- CREATE TABLE Syntax
- CREATE INDEX Syntax
- DROP TABLE Syntax
- DROP INDEX Syntax
- ALTER TABLE Syntax
- TRUNCATE TABLE Syntax
DML 语法兼容
- INSERT Syntax
- REPLACE Syntax
- UPDATE Syntax
- DELETE Syntax
- Subquery Syntax
- Scalar Subquery
- Comparisons Subquery
- Subqueries with ANY, IN, or SOME
- Subqueries with ALL
- Row Subqueries
- Subqueries with EXISTS or NOT EXISTS
- Subqueries in the FROM Clause
- SELECT Syntax
Prepare 语法兼容
- PREPARE Syntax
- EXECUTE Syntax
- DEALLOCATE PREPARE Syntax
数据库管理语法兼容
- SET Syntax
- SHOW Syntax
- SHOW COLUMNS Syntax
- SHOW CREATE TABLE Syntax
- SHOW INDEX
- SHOW TABLES Syntax
- SHOW TABLE STATUS Syntax
- SHOW TABLE STATUS Syntax
- SHOW TABLES Syntax
- SHOW VARIABLES Syntax
- SHOW WARNINGS Syntax
- SHOW ERRORS Syntax
- 其他 SHOW 指令会默认下发到 DB 处理,结果数据没有进行分库数据合并
- KILL ‘PROCESS_ID’ ( DRDS 不支持 KILL QUERY 指令,只支持 KILL ‘PROCESS_ID’ )
数据库工具指令
- DESCRIBE Syntax
- EXPLAIN Syntax
- USE Syntax
DRDS 自定义指令
- SHOW SEQUENCES / CREATE SEQUENCE / ALTER SEQUENCE / DROP SEQUENCE 【 DRDS 全局唯一数字序列管理】
- SHOW PARTITIONS FROM TABLE 【查询表的拆分字段】
- SHOW TOPOLOGY FROM TABLE 【查询表的物理拓扑】
- SHOW BROADCASTS 【查询所有广播表】
- SHOW RULE [FROM TABLE] 【查询表拆分定义】
- SHOW DATASOURCES 【查询后端 DB 连接池定义】
- SHOW DBLOCK / RELEASE DBLOCK 【分布式 LOCK 定义】
- SHOW NODE 【查询读写库流量】
- SHOW SLOW 【查询慢 SQL 列表】
- SHOW PHYSICAL_SLOW 【查询物理 DB 执行慢 SQL 列表】
- TRACE SQL_STATEMENT / SHOW TRACE 【跟踪 SQL 整个执行过程】
- EXPLAIN [DETAIL/EXECUTE] SQL_STATEMENT 【分析 DRDS 执行计划和物理 DB 上的执行计划】
- RELOAD USERS 【同步 DRDS 控制台用户信息到 DRDS SERVER】
- RELOAD SCHEMA 【清理 DRDS 对应 DB 库数据缓存,比如 SQL 解析/语法树/表结构缓存】
- RELOAD DATASOURCES 【重建后端与所有 DB 的连接池】
数据库函数
- 带拆分键的 SQL ,所有 MySQL 函数支持。
- 不带拆分键的 SQL,部分函数支持。
操作符函数
| 函数表达式 | 函数描述 |
|---|---|
| AND, && | Logical AND |
| = | Assign a value (as part of a SET statement, or as part of the SET clause in an UPDATE statement) |
| BETWEEN … AND … | Check whether a value is within a range of value |
| BINARY | Cast a string to a binary string |
| & | Bitwise AND |
| ~ | Bitwise inversion |
| ^ | Bitwise XOR |
| DIV | Integer division |
| / | Division operator |
| <=> | NULL-safe equal to perator |
| = | Equal operator |
| >= | Greater than or equal operator |
| > | Greater than operator |
| IS NOT NULL | NOT NULL value test |
| IS NOT | Test a value against a boolean |
| IS NULL | NULL value test |
| IS | Test a value against a boolean |
| << | Left shift |
| <= | Less than or equal operator |
| < | Less than operator |
| LIKE | Simple pattern matching |
| - | Minus operator |
| %, | MODModulo operator |
| NOT BETWEEN … AND … | Check whether a value is not within a range of values |
| !=, <> | Not equal operator |
| NOT LIKE | Negation of simple pattern matching |
| NOT REGEXP | Negation of REGEXP |
| NOT, ! | Negates value |
| OR | Logical OR |
| + | Addition operator |
| REGEXP | Pattern matching using regular expressions |
| >> | Right shift |
| RLIKE | Synonym for REGEXP |
| * | Multiplication operator |
| - | Change the sign of the argument |
| XOR | Logical XOR |
| Coalesce | Return the first non-NULL argument |
| GREATEST | Return the largest argument |
| LEAST | Return the smallest argument |
| STRCMP | Compare two strings |
流程控制函数
| Function | Description |
|---|---|
| CASE | Case operator |
| IF() | If/else construct |
| IFNULL() | Null if/else construct |
| NULLIF() | Return NULL if expr1 = expr2 |
数学函数
| Function | Description |
|---|---|
| ABS() | Return the absolute value |
| ACOS() | Return the arc cosine |
| ASIN() | Return the arc sine |
| ATAN2(),ATAN() | Return the arc tangent of the two arguments |
| ATAN() | Return the arc tangent |
| CEIL() | Return the smallest integer value not less than the argument |
| CEILIG() | Return the smallest integer value not less than the argument |
| CONV() | Convert numbers between different number bases |
| COS() | Return the cosine |
| COT() | Return the cotangent |
| CRC32() | Compute a cyclic redundancy check value |
| DEGREES() | Convert radians to degrees |
| DIV | Intger division |
| EXP() | Raise to the power of |
| FLOOR() | Return the largest integer value not greater than the argument |
| LN() | Return the natural logarithm of the argument |
| LOG10() | Return the base-10 logarithm of the argument |
| LOG2() | Return the base-2 logarithm of the argument |
| LOG() | Return the natural logarithm of the first argument |
| MOD() | Return the remainder |
| %, MOD | Modulo operator |
| PI() | Return the value of pi |
| POW() | Return the argument raised to the specified power |
| POWER() | Return the argument raised to the specified power |
| RADIANS() | Return argument converted to radians |
| RAND() | Return a random floating-point value |
| ROUND() | Round the argument |
| SIGN() | Return the sign of the argument |
| SIN() | Return the sine of the argument |
| SQRT() | Return the square root of the argument |
| TAN() | Return the tangent of the argument |
| TRUNCATE( | Truncate to specified number of decimal places |
字符串函数
| Function | Description |
|---|---|
| ASCII() | Return numeric value of left-most character |
| BIN() | Return a string containing binary representation of a number |
| BIT_LENGTH() | Return length of argument in bits |
| CHAR_LENGTH() | Return number of characters in argument |
| CHAR() | Return the character for each integer passed |
| CHARACTER_LENGTH() | Synonym for CHAR_LENGTH() |
| CONCAT_WS() | Return concatenate with separator |
| CONCAT() | Return concatenated string |
| ELT() | Return string at index number |
| EXPORT_SET() | Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string |
| FIELD() | Return the index (position) of the first argument in the subsequent arguments |
| FIND_IN_SET() | Return the index position of the first argument within the second argument |
| FORMAT() | Return a number formatted to specified number of decimal places |
| HEX() | Return a hexadecimal representation of a decimal or string value |
| INSERT() | Insert a substring at the specified position up to the specified number of characters |
| INSTR() | Return the index of the first occurrence of substring |
| LCASE() | Synonym for LOWER() |
| LEFT() | Return the leftmost number of characters as specified |
| LENGTH() | Return the length of a string in bytes |
| LIKE | Simple pattern matching |
| LOCATE() | Return the position of the first occurrence of substring |
| LOWER() | Return the argument in lowercase |
| LPAD() | Return the string argument, left-padded with the specified string |
| LTRIM() | Remove leading spaces |
| MAKE_SET() | Return a set of comma-separated strings that have the corresponding bit in bits set |
| MID() | Return a substring starting from the specified position |
| NOT LIKE | Negation of simple pattern matching |
| NOT REGEXP | Negation of REGEXP |
| OCT() | Return a string containing octal representation of a number |
| OCTET_LENGTH() | Synonym for LENGTH() |
| ORD() | Return character code for leftmost character of the argument |
| POSITION() | Synonym for LOCATE() |
| QUOTE() | Escape the argument for use in an SQL statement |
| REPEAT() | Repeat a string the specified number of times |
| REPLACE() | Replace occurrences of a specified string |
| REVERSE() | Reverse the characters in a string |
| RIGHT() | Return the specified rightmost number of characters |
| RPAD() | Append string the specified number of times |
| RTRIM() | Remove trailing spaces |
| SPACE() | Return a string of the specified number of spaces |
| STRCMP() | Compare two strings |
| SUBSTR() | Return the substring as specified |
| SUBSTRING_INDEX() | Return a substring from a string before the specified number of occurrences of the delimiter |
| SUBSTRING() | Return the substring as specified |
| TRIM() | Remove leading and trailing spaces |
| UCASE() | Synonym for UPPER() |
| UNHEX() | Return a string containing hex representation of a number |
| UPPER() | Convert to uppercase |
时间函数
| Function | Description |
|---|---|
| ADDDATE() | Add time values (intervals) to a date value |
| ADDTIME() | Add time |
| CURDATE() | Return the current date |
| CURRENT_DATE() | CURRENT_DATE Synonyms for CURDATE() |
| CURRENT_TIME() | CURRENT_TIME Synonyms for CURTIME() |
| CURRENT_TIMESTAMP() | CURRENT_TIMESTAMP Synonyms for NOW() |
| CURTIME() | Return the current time |
| DATE_ADD() | Add time values (intervals) to a date value |
| DATE_FORMAT() | Format date as specified |
| DATE_SUB() | Subtract a time value (interval) from a date |
| DATE() | Extract the date part of a date or datetime expression |
| DATEDIFF() | Subtract two dates |
| DAY() | Synonym for DAYOFMONTH() |
| DAYNAME() | Return the name of the weekday |
| DAYOFMONTH() | Return the day of the month (0-31) |
| DAYOFWEEK() | Return the weekday index of the argument |
| DAYOFYEAR() | Return the day of the year (1-366) |
| EXTRACT() | Extract part of a date |
| FROM_DAYS() | Convert a day number to a date |
| FROM_UNIXTIME() | Format UNIX timestamp as a date |
| GET_FORMAT() | Return a date format string |
| HOUR() | Extract the hour |
| LAST_DAY() | Return the last day of the month for the argument |
| LOCALTIME() | LOCALTIME Synonym for NOW() |
| LOCALTIMESTAMP, LOCALTIMESTAMP() | Synonym for NOW() |
| MAKEDATE() | Create a date from the year and day of year |
| MAKETIME() | Create time from hour, minute, second |
| MICROSECOND() | Return the microseconds from argument |
| MINUTE() | Return the minute from the argument |
| MONTH() | Return the month from the date passed |
| MONTHNAME() | Return the name of the month |
| NOW() | Return the current date and time |
| PERIOD_ADD() | Add a period to a year-month |
| PERIOD_DIFF() | Return the number of months between periods |
| QUARTER() | Return the quarter from a date argument |
| SEC_TO_TIME() | Converts seconds to ‘HH:MM:SS’ format |
| SECOND() | Return the second (0-59) |
| STR_TO_DATE() | Convert a string to a date |
| SUBDATE() | Synonym for DATE_SUB() when invoked with three arguments |
| SUBTIME() | Subtract times |
| SYSDATE() | Return the time at which the function executes |
| TIME_FORMAT() | Format as time |
| TIME_TO_SEC() | Return the argument converted to seconds |
| TIME() | Extract the time portion of the expression passed |
| TIMEDIFF() | Subtract time |
| TIMESTAMP() | With a single argument, this function returns the date or datetime expression; with two arguments, the sum of the arguments |
| TIMESTAMPADD() | Add an interval to a datetime expression |
| TIMESTAMPDIFF() | Subtract an interval from a datetime expression |
| UNIX_TIMESTAMP() | Return a UNIX timestamp |
| UTC_DATE() | Return the current UTC date |
| UTC_TIME() | Return the current UTC time |
| UTC_TIMESTAMP() | Return the current UTC date and time |
| WEEKDAY() | Return the weekday index |
| WEEKOFYEAR() | Return the calendar week of the date (1-53) |
| YEAR() | Return the year |
类型转换函数
| Function | Description |
|---|---|
| BINARY | Cast a string to a binary string |
| CAST() | Cast a value as a certain type |
| CONVERT() | Cast a value as a certain type |
DRDS SQL兼容性的更多相关文章
- DRDS SQL 审计与分析——全面洞察 SQL 之利器
背景 数据库存储着系统的核心数据,其安全方面的问题在传统环境中已经成为泄漏和被篡改的重要根源.而在云端,数据库所面临的威胁被进一步的放大.因此,对云数据库的操作行为尤其是全量 SQL 执行记录的审计日 ...
- 第三代DRDS分布式SQL引擎全新发布
DRDS (阿里云分布式关系型数据库服务,https://www.aliyun.com/product/drds)于 4 月 30 号发布了 5.3 版本,这是一个年度大更新.主要带来了以下特性: 性 ...
- 云时代的分布式数据库:阿里分布式数据库服务DRDS
发表于2015-07-15 21:47| 10943次阅读| 来源<程序员>杂志| 27 条评论| 作者王晶昱 <程序员>杂志数据库DRDS分布式沈询 摘要:伴随着系统性能.成 ...
- 跨时代的分布式数据库 – 阿里云DRDS详解(转)
原文章地址:https://www.csdn.net/article/a/2015-08-28/15827676 跨时代的分布式数据库 – 阿里云DRDS详解 发表于2015-08-28 18:39| ...
- DRDS 数据恢复重磅发布,全方位保障您的数据安全
背景介绍 数据库存储着企业的核心数据,在企业中占据非常重要的位置,一旦出现SQL注入,数据误删的情况,影响的不仅仅是业务,还会泄露用户的个人信息.因此,数据库的数据安全问题十分重要. 当数据库迁移到云 ...
- 达梦产品技术支持培训-day2-DM8常用SQL
(本文只作为随笔或个人笔记,非官方文档,请勿作他用,谢谢) DM8数据库的SQL兼容性很高,和Oracle差距不大,以下是个人认为比较关键的部分. 1.关键动词 create --新建 drop -- ...
- 分库分表 or NewSQL数据库?终于看懂应该怎么选!【转】
最近与同行科技交流,经常被问到分库分表与分布式数据库如何选择,网上也有很多关于中间件+传统关系数据库(分库分表)与NewSQL分布式数据库的文章,但有些观点与判断是我觉得是偏激的,脱离环境去评价方案好 ...
- 【转】 MySQL与PostgreSQL:该选择哪个开源数据库?哪一个更好?
转载地址:http://www.infoq.com/cn/news/2013/12/mysql-vs-postgresql 如果打算为项目选择一款免费.开源的数据库,那么你可能会在MySQL与Post ...
- 聚集索引、非聚集索引、聚集索引组织表、堆组织表、Mysql/PostgreSQL对比、联合主键/自增长、InnoDB/MyISAM(引擎方面另开一篇)
参考了多篇文章,分别记录,如下. 下面是第一篇的总结 http://www.jb51.net/article/76007.htm: 在MySQL中,InnoDB引擎表是(聚集)索引组织表(cluste ...
随机推荐
- FastDFS 配置 Nginx 模块,并实现分布式同步-Linux
1.搭建虚拟机 a.复制虚拟机文件 首先复制我们之前安装好的fastdfs虚拟机,因为我们现在要设置它的IP为21,改名为CentOS-fastdfs - 21. b.设置网络 生成新的MAC地址 设 ...
- SFTP 常用命令 —— SecureCRT版本
SecureCRT按下ALT+P就开启新的会话 进行ftp操作. 输入:help命令,显示该FTP提供所有的命令 pwd: 查询linux主机所在目录(也就是远程主机目录) lpwd: 查询本地目录( ...
- JAVA项目常用异常处理情况
Java异常处理 网络整理 这里是异常的说明: 算术异常类:ArithmeticExecption 空指针异常类:NullPointerException 类型强制转换异常:ClassCastExce ...
- Python基础4 迭代器、装饰器、软件开发规范
本节内容 迭代器&生成器 装饰器 Json & pickle 数据序列化 软件目录结构规范 作业:ATM项目开发 1.列表生成式,迭代器&生成器 列表生成式 孩子,我现在有个需 ...
- Nginx 服务器搭建
什么是Nginx ? Nginx与Apache IIS等软件一样,是一款服务器软件,为web站点提供服务 除此之外,Nginx 还是一款反向代理服务器,我们可以利用Nginx实现负载均衡 所谓负载均衡 ...
- js/jquery this 坑
重要:js onclick() 函数中,取不到this !!! 错误的写法: function test(){ $(this).parent().addClass('active') } 正确的写法是 ...
- 详述 IntelliJ IDEA 插件的安装及使用方法
首先,进入插件安装界面: Mac:IntelliJ IDEA -> Preferences -> Plugins; Windows:File -> Settings -> Pl ...
- 机器学习进阶-目标追踪-SSD多进程执行 1.cv2.dnn.readnetFromCaffe(用于读取已经训练好的caffe模型) 2.delib.correlation_tracker(生成追踪器) 5.cv2.writer(将图片写入视频中) 6.cv2.dnn.blobFromImage(图片归一化) 10.multiprocessing.process(生成进程)
1. cv2.dnn.readNetFromCaffe(prototxt, model) 用于进行SSD网络的caffe框架的加载 参数说明:prototxt表示caffe网络的结构文本,model ...
- Redis脚本
8.启动 /usr/local/bin/redis-server /etc/redis/redis.conf ./redis-server /home/work/redis/redis.conf &a ...
- 应用SharedPreference保存程序的配置信息
SharedPreference: 1.用来保存应用程序的配置信息的XML文件,内部的数据形式为键值对 2.一般存在于/data/data/<包名>shared_prefs目录下 3.该对 ...