Skip to content

Latest commit

 

History

History
96 lines (72 loc) · 1.24 KB

sql-statement-table.md

File metadata and controls

96 lines (72 loc) · 1.24 KB
title summary
TABLE | TiDB SQL Statement Reference
An overview of the usage of TABLE for the TiDB database.

TABLE

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

Synopsis

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

Examples

{{< copyable "sql" >}}

CREATE TABLE t1(id INT PRIMARY KEY);
Query OK, 0 rows affected (0.31 sec)

{{< copyable "sql" >}}

INSERT INTO t1 VALUES (1),(2),(3);
Query OK, 3 rows affected (0.06 sec)
Records: 3  Duplicates: 0  Warnings: 0

{{< copyable "sql" >}}

TABLE t1;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.01 sec)

{{< copyable "sql" >}}

TABLE t1 ORDER BY id DESC;
+----+
| id |
+----+
|  3 |
|  2 |
|  1 |
+----+
3 rows in set (0.01 sec)

{{< copyable "sql" >}}

TABLE t1 LIMIT 1;
+----+
| id |
+----+
|  1 |
+----+
1 row in set (0.01 sec)

MySQL compatibility

The TABLE statement was introduced in MySQL 8.0.19.

See also