SHOW SINGLE TABLE

描述

SHOW SINGLE TABLE 语法用于查询指定逻辑库中的单表。

语法

Grammar Railroad diagram

  1. ShowSingleTable::=
  2. 'SHOW' 'SINGLE' ('TABLES' ('LIKE' likeLiteral)?|'TABLE' tableName) ('FROM' databaseName)?
  3. tableName ::=
  4. identifier
  5. databaseName ::=
  6. identifier

补充说明

  • 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected

返回值说明

说明
table_name单表名称
resource_name单表所在的数据源名称

示例

  • 查询指定逻辑库中的指定单表
  1. SHOW SINGLE TABLE t_user FROM sharding_db;
  1. mysql> SHOW SINGLE TABLE t_user FROM sharding_db;
  2. +------------+---------------+
  3. | table_name | resource_name |
  4. +------------+---------------+
  5. | t_user | ds_0 |
  6. +------------+---------------+
  7. 1 row in set (0.00 sec)
  • 查询当前逻辑库中的指定单表
  1. SHOW SINGLE TABLE t_user;
  1. mysql> SHOW SINGLE TABLE t_user;
  2. +------------+---------------+
  3. | table_name | resource_name |
  4. +------------+---------------+
  5. | t_user | ds_0 |
  6. +------------+---------------+
  7. 1 row in set (0.00 sec)
  • 查询指定逻辑库中的单表
  1. SHOW SINGLE TABLES FROM sharding_db;
  1. mysql> SHOW SINGLE TABLES FROM sharding_db;
  2. +------------+---------------+
  3. | table_name | resource_name |
  4. +------------+---------------+
  5. | t_user | ds_0 |
  6. +------------+---------------+
  7. 1 row in set (0.00 sec)
  • 查询当前逻辑库中的单表
  1. SHOW SINGLE TABLES;
  1. mysql> SHOW SINGLE TABLES;
  2. +------------+---------------+
  3. | table_name | resource_name |
  4. +------------+---------------+
  5. | t_user | ds_0 |
  6. +------------+---------------+
  7. 1 row in set (0.00 sec)
  • 查询指定逻辑库中表名以 order_5 结尾的单表
  1. SHOW SINGLE TABLES LIKE '%order_5' FROM sharding_db;
  1. mysql> SHOW SINGLE TABLES LIKE '%order_5' FROM sharding_db;
  2. +------------+-------------------+
  3. | table_name | storage_unit_name |
  4. +------------+-------------------+
  5. | t_order_5 | ds_1 |
  6. +------------+-------------------+
  7. 1 row in set (0.11 sec)
  • 查询当前逻辑库中表名以 order_5 结尾的单表
  1. SHOW SINGLE TABLES LIKE '%order_5';
  1. mysql> SHOW SINGLE TABLES LIKE '%order_5';
  2. +------------+-------------------+
  3. | table_name | storage_unit_name |
  4. +------------+-------------------+
  5. | t_order_5 | ds_1 |
  6. +------------+-------------------+
  7. 1 row in set (0.11 sec)

保留字

SHOWSINGLETABLETABLESLIKEFROM

相关链接