TABLE

The TABLE statement can be used instead of SELECT * FROM when no aggregation or complex filtering is needed.

Synopsis

TableStmt

TABLE - 图1

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

Examples

Create table t1:

  1. CREATE TABLE t1(id INT PRIMARY KEY);

Insert some data into t1:

  1. INSERT INTO t1 VALUES (1),(2),(3);

View the data in table t1:

  1. TABLE t1;
  1. +----+
  2. | id |
  3. +----+
  4. | 1 |
  5. | 2 |
  6. | 3 |
  7. +----+
  8. 3 rows in set (0.01 sec)

Query t1 and sort the result by the id field in descending order:

  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)

Query the first record in t1:

  1. TABLE t1 LIMIT 1;
  1. +----+
  2. | id |
  3. +----+
  4. | 1 |
  5. +----+
  6. 1 row in set (0.01 sec)

MySQL compatibility

The TABLE statement was introduced in MySQL 8.0.19.

See also