阅读(2041)
赞(13)
Mycat2 Sql兼容性 select
2021-09-08 11:47:50 更新
select兼容性
query:
select:
SELECT [ ALL | DISTINCT ]
{ * | projectItem [, projectItem ]* }
FROM tableExpression
[ WHERE booleanExpression ]
[ GROUP BY { groupItem [, groupItem ]* } ]
[ HAVING booleanExpression ]
selectWithoutFrom:
SELECT [ ALL | DISTINCT ]
{ * | projectItem [, projectItem ]* }
projectItem:
expression [ [ AS ] columnAlias ]
| tableAlias . *
tableExpression:
tableReference [, tableReference ]*
| tableExpression [ NATURAL ] [ ( LEFT | RIGHT | FULL ) [ OUTER ] ] JOIN tableExpression [ joinCondition ]
| tableExpression CROSS JOIN tableExpression
| tableExpression [ CROSS | OUTER ] APPLY tableExpression
joinCondition:
ON booleanExpression
| USING '(' column [, column ]* ')'
tableReference:
tablePrimary
[ [ AS ] alias [ '(' columnAlias [, columnAlias ]* ')' ] ]
|tablePrimary:
[ [ catalogName . ] schemaName . ] tableName
'(' TABLE [ [ catalogName . ] schemaName . ] tableName ')'
|values:
VALUES expression [, expression ]*
groupItem:
expression
| '(' ')'
| '(' expression [, expression ]* ')'
SELECT UNION [ALL | DISTINCT] SELECT ...
when case语法
CASE case_value
WHEN booleanExpression THEN expression
[WHEN booleanExpression THEN expression] ...
[ELSE expression]
END CASE
单表,全局表
会转发sql
对于分片表
生成的sql
模板会带有for update
语句,在涉及多个存储节点的时候,sql执行的锁的范围比所需单节点sql
的大,所以尽量编写查询单节点的sql
,一般就是select ...from where ......for update
- 不支持
select into outfile
- 不支持
select use/ignore index
- 不支持
STRAIGHT_JOIN和 NATURAL JOIN
- 不支持有歧义的别名
错误
SELECT t.user_id FROM db1.travelrecord t GROUP BY id;
Expression 't.user_id' is not being grouped
修改成
SELECT any_value(t.user_id) FROM db1.travelrecord t GROUP BY id;
projectItem
被group by
的引用的无聚合函数的字段需要使用any_value
order by
必须引用select item
中存在的字段
子查询需要带有别名
project Item
不支持相同的字段名
limit
,offset
不能超过2147483647
且大于等于0