TiDBTiDB Docs Dash 2024

Jan 9 - Jan 12 (UTC)
Join us to improve docs and win a prize!
Sign InTry Free

TABLE

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

Synopsis

TableStmt
TABLETableORDER BYColumnLIMITNUM

Examples

Create table t1:

CREATE TABLE t1(id INT PRIMARY KEY);

Insert some data into t1:

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

View the data in table t1:

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

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

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

Query the first record in t1:

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

Was this page helpful?

Download PDFRequest docs changesAsk questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.