TABLE

当不需要聚合或复杂的过滤操作时,可以用 TABLE 语句代替 SELECT * FROM

语法图

  1. TableStmt ::=
  2. "TABLE" Table ( "ORDER BY" Column )? ( "LIMIT" NUM )?

示例

  1. CREATE TABLE t1(id INT PRIMARY KEY);
  1. Query OK, 0 rows affected (0.31 sec)
  1. INSERT INTO t1 VALUES (1),(2),(3);
  1. Query OK, 3 rows affected (0.06 sec)
  2. Records: 3 Duplicates: 0 Warnings: 0
  1. TABLE t1;
  1. +----+
  2. | id |
  3. +----+
  4. | 1 |
  5. | 2 |
  6. | 3 |
  7. +----+
  8. 3 rows in set (0.01 sec)
  1. TABLE t1 ORDER BY id DESC;
  1. +----+
  2. | id |
  3. +----+
  4. | 3 |
  5. | 2 |
  6. | 1 |
  7. +----+
  8. 3 rows in set (0.01 sec)
  1. TABLE t1 LIMIT 1;
  1. +----+
  2. | id |
  3. +----+
  4. | 1 |
  5. +----+
  6. 1 row in set (0.01 sec)

MySQL 兼容性

TABLE 语句是从 MySQL 8.0.19 开始引入的。

另请参阅