3.7 Utility Statements

3.7.1 USE Statement

完全兼容MySQL语法

USE db_name

例:

use TESTDB;

3.7.2 EXPLAIN Statement

EXPLAIN 在dble中只负责查询计划,查询计划用法见2.17_explain

EXPLAIN explainable_stmt

explainable_stmt: {
    SELECT statement
  | DELETE statement
  | INSERT statement
  | REPLACE statement
  | UPDATE statement
}

与MySQL语法区别

下文中红色表示不支持的语法或关键字

-{EXPLAIN | DESCRIBE | DESC}
-   tbl_name [col_name | wild]

-{
EXPLAIN 
-  | DESCRIBE | DESC}
-   [explain_type]
-   {
    explainable_stmt 
-    | FOR CONNECTION connection_id}

-{EXPLAIN | DESCRIBE | DESC} ANALYZE [FORMAT = TREE] select_statement

-explain_type: {
-    FORMAT = format_name
-}

-format_name: {
-    TRADITIONAL
-  | JSON
-  | TREE
-}

explainable_stmt: {
    SELECT statement
-  | TABLE statement
  | DELETE statement
  | INSERT statement
  | REPLACE statement
  | UPDATE statement
}

例:

explain SELECT select * from a_test where id=1;

注意事项:

  1. INSERT中表不能为自增序列表

  2. 在dble中,EXPLAIN 不等价于于DESC

3.7.3 DESC

DESC在dble中只负责查看数据表结构

{DESCRIBE | DESC} tbl_name [col_name | wild]

与MySQL语法区别

下文中红色表示不支持的语法或关键字

{EXPLAIN | DESCRIBE | DESC}
   tbl_name [col_name | wild]

-{
-EXPLAIN 
-  | DESCRIBE | DESC}
-   [explain_type]
-   {
-    explainable_stmt 
-    | FOR CONNECTION connection_id}

-{EXPLAIN | DESCRIBE | DESC} ANALYZE [FORMAT = TREE] select_statement

-explain_type: {
-    FORMAT = format_name
-}

-format_name: {
-    TRADITIONAL
-  | JSON
-  | TREE
-}

-explainable_stmt: {
-    SELECT statement
-  | TABLE statement
-  | DELETE statement
-  | INSERT statement
-  | REPLACE statement
-  | UPDATE statement
-}

例:

DESC a_test id;

注意: 在dble中,EXPLAIN 不等价于于DESC

3.7.4 EXPLAIN2

查询计划2用法见2.17_explain

EXPLAIN2 shardingNode=node_name sql=sql_stmt

例:

explain2 shardingNode=dn2 sql=select * from a_test where id=1;

3.7.5 HELP Statement 不支持

results matching ""

    No results matching ""