跨数据库查询DSQL,兼容MySQL协议和语法,但由于分布式场景下和单机数据库存在一定差异,同时考虑到安全风险,在SQL使用上存在一些限制。具体支持的SQL语法如下。
select
SELECT
[ALL | DISTINCT | DISTINCTROW ]
select_expr [, select_expr ...]
[FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | expr | position}]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
注意:
SQL语句中的表名,需要加dblink和db前缀,即table_references应该为dblink.db.table的形式,否则系统无法得知该SQL需要查询哪个实例上的数据。
insert
INSERT INTO dblink.db.tbl_name
[(col_name [, col_name] ...)]
{VALUES | VALUE} (value_list) [, (value_list)] ...
value:
{expr | DEFAULT}
value_list:
value [, value] ...
insert into select
INSERT INTO dblink.db.tbl_name
[(col_name [, col_name] ...)]
SELECT ...
create table as select
CREATE TABLE [IF NOT EXISTS] dblink.db.tbl_name
[AS] query_expression
query_expression:
SELECT ... (Some valid select or union statement)
delete
DELETE FROM dblink.db.tbl_name
WHERE where_condition
注意:
where_condition不能包含子查询;此外,当待删除的数据来自Redis时,where_condition必须是关于Redis key的表达式(如:key = ‘xxx’,或key LIKE ‘pattern%’)。
文档内容是否对您有帮助?