top of page
CerebroSQL

TABLE

База данных: MySQL

68747470733a2f2f7374796c65732e7265646469746d656469612e636f6d2f74355f32716d366b2f7374796c65

Syntax:
TABLE is a DML statement introduced in MySQL 8.0.19 which returns rows
and columns of the named table.

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

The TABLE statement in some ways acts like SELECT. Given the existance
of a table named t, the following two statements produce identical
output:

TABLE t;

SELECT * FROM t;

You can order and limit the number of rows produced by TABLE using
ORDER BY and LIMIT clauses, respectively. These function identically to
the same clauses when used with SELECT (including an optional OFFSET
clause with LIMIT), as you can see here:

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:

o TABLE always displays all columns of the table.

o TABLE does not allow for any arbitrary filtering of rows; that is,
TABLE does not support any WHERE clause.

For limiting which table columns are returned, filtering rows beyond
what can be accomplished using ORDER BY and LIMIT, or both, use SELECT.

TABLE can be used with temporary tables.

URL: https://dev.mysql.com/doc/refman/8.0/en/table.html

Example

bottom of page