13.2.12 TABLE Statement语句

TABLE is a DML statement introduced in MySQL 8.0.19 which returns rows and columns of the named table.TABLE是MySQL8.0.19中引入的DML语句,它返回命名表的行和列。

TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]

The TABLE statement in some ways acts like SELECT. TABLE语句在某些方面的作用类似于SELECTGiven the existance of a table named t, the following two statements produce identical output:给定名为t的表的存在,以下两个语句产生相同的输出:

TABLE t;

SELECT * FROM t;

You can order and limit the number of rows produced by TABLE using ORDER BY and LIMIT clauses, respectively. 您可以分别使用ORDER BYLIMIT子句对TABLE生成的行数进行排序和限制。These function identically to the same clauses when used with SELECT (including an optional OFFSET clause with LIMIT), as you can see here:SELECT一起使用时,这些子句的功能与相同的子句相同(包括带LIMIT的可选OFFSET子句),如下所示:

mysql> TABLE t;
+----+----+
| a  | b  |
+----+----+
|  1 |  2 |
|  6 |  7 |
|  9 |  5 |
| 10 | -4 |
| 11 | -1 |
| 13 |  3 |
| 14 |  6 |
+----+----+
7 rows in set (0.00 sec)

mysql> TABLE t ORDER BY b;
+----+----+
| a  | b  |
+----+----+
| 10 | -4 |
| 11 | -1 |
|  1 |  2 |
| 13 |  3 |
|  9 |  5 |
| 14 |  6 |
|  6 |  7 |
+----+----+
7 rows in set (0.00 sec)

mysql> TABLE t LIMIT 3;
+---+---+
| a | b |
+---+---+
| 1 | 2 |
| 6 | 7 |
| 9 | 5 |
+---+---+
3 rows in set (0.00 sec)

mysql> TABLE t ORDER BY b LIMIT 3;
+----+----+
| a  | b  |
+----+----+
| 10 | -4 |
| 11 | -1 |
|  1 |  2 |
+----+----+
3 rows in set (0.00 sec)

mysql> TABLE t ORDER BY b LIMIT 3 OFFSET 2;
+----+----+
| a  | b  |
+----+----+
|  1 |  2 |
| 13 |  3 |
|  9 |  5 |
+----+----+
3 rows in set (0.00 sec)

TABLE differs from SELECT in two key respects:TABLE在两个关键方面与SELECT不同:

For limiting which table columns are returned, filtering rows beyond what can be accomplished using ORDER BY and LIMIT, or both, use SELECT.要限制返回的表列,请使用SELECT筛选超出使用ORDER BYLIMIT(或两者)可以完成的范围的行。

TABLE can be used with temporary tables.TABLE可以与临时表一起使用。

TABLE can also be used in place of SELECT in a number of other constructs, including those listed here:TABLE还可以在许多其他构造中代替SELECT,包括下面列出的构造: