From 772e3c4f2c2a2ba4b45ecd8f4c1ca785a0855b1a Mon Sep 17 00:00:00 2001 From: qw4990 Date: Mon, 16 Oct 2023 20:48:09 +0800 Subject: [PATCH 01/15] fixup --- sql-statements/sql-statement-select.md | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 6628d35a5478e..dee3fa6ad2ef3 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -117,6 +117,8 @@ TableSampleOpt ::= ## Examples +### SELECT + ```sql mysql> CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, c1 INT NOT NULL); Query OK, 0 rows affected (0.11 sec) @@ -158,6 +160,64 @@ mysql> SELECT AVG(s_quantity), COUNT(s_quantity) FROM stock; The above example uses data generated with `tiup bench tpcc prepare`. The first query shows the use of `TABLESAMPLE`. +### SELECT ... INTO OUTFILE + +`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Column and line terminators can be specified to produce a specific output format. + +You can use the `Fields` and `Lines` parameters to specify how to handle the data format. + +- `FIELDS TERMINATED BY`: specifies the data delimiter. +- `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. +- `LINES TERMINATED BY`: specifies the line terminator, if you want to end a line with a certain character. + +Below are some examples, first create a table and prepare some data: + +```sql +mysql> create table t (a int, b varchar(10), c decimal(10,2)); +Query OK, 0 rows affected (0.02 sec) + +mysql> insert into t values (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); +Query OK, 3 rows affected (0.01 sec) +``` + +Then here are some `SELECT ... INTO OUTFILE` statements and their results. + +```sql +mysql> select * from t into outfile '/tmp/tmp_file1'; +Query OK, 3 rows affected (0.00 sec) +``` + +``` +1 a 1.10 +2 b 2.20 +3 c 3.30 +``` + +```sql +mysql> select * from t into outfile '/tmp/tmp_file2' fields terminated by ',' enclosed by '"'; +Query OK, 3 rows affected (0.00 sec) +``` + +``` +"1","a","1.10" +"2","b","2.20" +"3","c","3.30" +``` + +```sql +mysql> select * from t into outfile '/tmp/tmp_file3' fields terminated by ',' enclosed by '\'' lines terminated by '<<<\n'; +Query OK, 3 rows affected (0.00 sec) +``` + +``` +'1','a','1.10'<<< +'2','b','2.20'<<< +'3','c','3.30'<<< +``` + + +Now `SELECT ... INTO @variable`, `SELECT ... INTO DUMPFILE` or any [external storage](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) like S3 or GCS is not supported. + ## MySQL compatibility - The syntax `SELECT ... INTO @variable` is not supported. From 970d0e97e98cee137a2e91b00df8e07304f70177 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Mon, 16 Oct 2023 20:50:20 +0800 Subject: [PATCH 02/15] fixup --- sql-statements/sql-statement-select.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index dee3fa6ad2ef3..e0c0657be71bc 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -215,7 +215,6 @@ Query OK, 3 rows affected (0.00 sec) '3','c','3.30'<<< ``` - Now `SELECT ... INTO @variable`, `SELECT ... INTO DUMPFILE` or any [external storage](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) like S3 or GCS is not supported. ## MySQL compatibility From 5bb5dc6bfbdc18793fc0cb152b81bc4a9da48980 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 17 Oct 2023 18:27:06 +0800 Subject: [PATCH 03/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index e0c0657be71bc..912f3b76be2c1 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -183,7 +183,7 @@ Query OK, 3 rows affected (0.01 sec) Then here are some `SELECT ... INTO OUTFILE` statements and their results. ```sql -mysql> select * from t into outfile '/tmp/tmp_file1'; +mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; Query OK, 3 rows affected (0.00 sec) ``` From c38182e7847c3118a252e3c8e46f68fabf85b09d Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 17 Oct 2023 18:27:17 +0800 Subject: [PATCH 04/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 912f3b76be2c1..6220088c225d9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -162,7 +162,7 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Column and line terminators can be specified to produce a specific output format. +`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Field and line terminators can be specified to produce a specific output format. Common output formats are comma separated (CSV) and tab separated (TSV). You can use the `Fields` and `Lines` parameters to specify how to handle the data format. From e4b64bbef108c8d5a197596a7c036c501006587d Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 17 Oct 2023 18:40:49 +0800 Subject: [PATCH 05/15] Update sql-statements/sql-statement-select.md --- sql-statements/sql-statement-select.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 6220088c225d9..28f70e4d580c9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -162,9 +162,7 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. Field and line terminators can be specified to produce a specific output format. Common output formats are comma separated (CSV) and tab separated (TSV). - -You can use the `Fields` and `Lines` parameters to specify how to handle the data format. +`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify how to handle the data format. Common output formats are comma separated (CSV) and tab separated (TSV). - `FIELDS TERMINATED BY`: specifies the data delimiter. - `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. From 2433a49dfd2fce3444bb0bd22dd5a0b2d0787925 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Wed, 18 Oct 2023 11:33:56 +0800 Subject: [PATCH 06/15] Update sql-statements/sql-statement-select.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-select.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 28f70e4d580c9..962fb51080914 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -178,7 +178,10 @@ mysql> insert into t values (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) ``` -Then here are some `SELECT ... INTO OUTFILE` statements and their results. +Here are some `SELECT ... INTO OUTFILE` statements and their results. + +Example 1: + ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; From 71d7bf87699653f14c53a6270517c745690a9725 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Wed, 18 Oct 2023 11:34:01 +0800 Subject: [PATCH 07/15] Update sql-statements/sql-statement-select.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-select.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 962fb51080914..8cdb2bd3cfba9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -188,6 +188,8 @@ mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; Query OK, 3 rows affected (0.00 sec) ``` +In this example, you can find the query result in `/tmp/tmp_file1` as follows: + ``` 1 a 1.10 2 b 2.20 From c35bebce89360ce205257ac43ad1b4a3226281df Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 30 Oct 2023 14:12:55 +0800 Subject: [PATCH 08/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 8cdb2bd3cfba9..74b855799ace5 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -171,12 +171,11 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first Below are some examples, first create a table and prepare some data: ```sql -mysql> create table t (a int, b varchar(10), c decimal(10,2)); +mysql> CREATE TABLE t (a INT, b VARCHAR(10), c DECIMAL(10,2)); Query OK, 0 rows affected (0.02 sec) -mysql> insert into t values (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); +mysql> INSERT INTO t VALUES (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) -``` Here are some `SELECT ... INTO OUTFILE` statements and their results. From 7ddea8588aabb0a76f0f7aa50df530de3fa128f5 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 30 Oct 2023 14:13:01 +0800 Subject: [PATCH 09/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 74b855799ace5..83c869da859ec 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -207,7 +207,8 @@ Query OK, 3 rows affected (0.00 sec) ``` ```sql -mysql> select * from t into outfile '/tmp/tmp_file3' fields terminated by ',' enclosed by '\'' lines terminated by '<<<\n'; +mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file3' + -> FIELDS TERMINATED BY ',' ENCLOSED BY '\'' LINES TERMINATED BY '<<<\n'; Query OK, 3 rows affected (0.00 sec) ``` From a38d59c26e42685f56052f0110f85c147dc7a2bf Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 30 Oct 2023 14:13:12 +0800 Subject: [PATCH 10/15] Update sql-statements/sql-statement-select.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 83c869da859ec..e46bd13d0bbc0 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -196,7 +196,7 @@ In this example, you can find the query result in `/tmp/tmp_file1` as follows: ``` ```sql -mysql> select * from t into outfile '/tmp/tmp_file2' fields terminated by ',' enclosed by '"'; +mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file2' FIELDS TERMINATED BY ',' ENCLOSED BY '"'; Query OK, 3 rows affected (0.00 sec) ``` From d3b17eb35177a5d24246b1a7c04adbc8e9844bdb Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Mon, 30 Oct 2023 15:34:06 +0800 Subject: [PATCH 11/15] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index e46bd13d0bbc0..1673fda6cea2f 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -176,12 +176,12 @@ Query OK, 0 rows affected (0.02 sec) mysql> INSERT INTO t VALUES (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) +``` Here are some `SELECT ... INTO OUTFILE` statements and their results. Example 1: - ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; Query OK, 3 rows affected (0.00 sec) From 528230133a640247eba578d4b56a1b5e8a1cad34 Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Mon, 30 Oct 2023 15:55:09 +0800 Subject: [PATCH 12/15] Apply suggestions from code review --- sql-statements/sql-statement-select.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 1673fda6cea2f..4ddcf67c6da73 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -162,13 +162,13 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -`SELECT ... INTO OUTFILE` is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify how to handle the data format. Common output formats are comma separated (CSV) and tab separated (TSV). +The `SELECT ... INTO OUTFILE` statement is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify the data format of the output file. Common output formats include comma-separated values (CSV) and tab-separated values (TSV). - `FIELDS TERMINATED BY`: specifies the data delimiter. - `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. - `LINES TERMINATED BY`: specifies the line terminator, if you want to end a line with a certain character. -Below are some examples, first create a table and prepare some data: +Assume that there is a table `t` with three columns as follows: ```sql mysql> CREATE TABLE t (a INT, b VARCHAR(10), c DECIMAL(10,2)); @@ -195,23 +195,31 @@ In this example, you can find the query result in `/tmp/tmp_file1` as follows: 3 c 3.30 ``` +Example 2: + ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file2' FIELDS TERMINATED BY ',' ENCLOSED BY '"'; Query OK, 3 rows affected (0.00 sec) ``` +In this example, you can find the query result in `/tmp/tmp_file2` as follows: + ``` "1","a","1.10" "2","b","2.20" "3","c","3.30" ``` +Example 3: + ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file3' -> FIELDS TERMINATED BY ',' ENCLOSED BY '\'' LINES TERMINATED BY '<<<\n'; Query OK, 3 rows affected (0.00 sec) ``` +In this example, you can find the query result in `/tmp/tmp_file3` as follows: + ``` '1','a','1.10'<<< '2','b','2.20'<<< From a5a9d93c27cc3b6888de10b0447b54fa2f80254a Mon Sep 17 00:00:00 2001 From: qiancai Date: Mon, 30 Oct 2023 16:48:43 +0800 Subject: [PATCH 13/15] refine the descriptions --- sql-statements/sql-statement-select.md | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 4ddcf67c6da73..b36f355e8f392 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -13,10 +13,6 @@ The `SELECT` statement is used to read data from TiDB. ![SelectStmt](/media/sqlgram/SelectStmt.png) -> **Note:** -> -> The `SELECT ... INTO OUTFILE` statement is only applicable to TiDB Self-Hosted and not available on [TiDB Cloud](https://docs.pingcap.com/tidbcloud/). - **FromDual:** ![FromDual](/media/sqlgram/FromDual.png) @@ -162,11 +158,19 @@ The above example uses data generated with `tiup bench tpcc prepare`. The first ### SELECT ... INTO OUTFILE -The `SELECT ... INTO OUTFILE` statement is used to write the result of a query to a file. You can use the `Fields` and `Lines` parameters to specify the data format of the output file. Common output formats include comma-separated values (CSV) and tab-separated values (TSV). +The `SELECT ... INTO OUTFILE` statement is used to write the result of a query to a file. + +> **Note:** +> +> - This statement is only applicable to TiDB Self-Hosted and not available on [TiDB Cloud](https://docs.pingcap.com/tidbcloud/). +> - This statement does not support +writing query results to any [external storages](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) such as Amazon S3 or GCS. -- `FIELDS TERMINATED BY`: specifies the data delimiter. -- `FIELDS ENCLOSED BY`: specifies the enclosing character of the data. -- `LINES TERMINATED BY`: specifies the line terminator, if you want to end a line with a certain character. +In the statement, you can specify the format of the output file by using the following clauses: + +- `FIELDS TERMINATED BY`: specifies the field delimiter in the file. For example, you can specify it as `','` to output comma-separated values (CSV) or `'\t'` to output tab-separated values (TSV). +- `FIELDS ENCLOSED BY`: specifies the enclosing character that wraps around each field in the file. +- `LINES TERMINATED BY`: specifies the line terminator in the file, if you want to end a line with a certain character. Assume that there is a table `t` with three columns as follows: @@ -178,9 +182,9 @@ mysql> INSERT INTO t VALUES (1, 'a', 1.1), (2, 'b', 2.2), (3, 'c', 3.3); Query OK, 3 rows affected (0.01 sec) ``` -Here are some `SELECT ... INTO OUTFILE` statements and their results. +The following examples show how to use the `SELECT ... INTO OUTFILE` statement to write the query result to a file. -Example 1: +**Example 1:** ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file1'; @@ -195,7 +199,7 @@ In this example, you can find the query result in `/tmp/tmp_file1` as follows: 3 c 3.30 ``` -Example 2: +**Example 2:** ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file2' FIELDS TERMINATED BY ',' ENCLOSED BY '"'; @@ -210,7 +214,7 @@ In this example, you can find the query result in `/tmp/tmp_file2` as follows: "3","c","3.30" ``` -Example 3: +**Example 3:** ```sql mysql> SELECT * FROM t INTO OUTFILE '/tmp/tmp_file3' @@ -226,11 +230,10 @@ In this example, you can find the query result in `/tmp/tmp_file3` as follows: '3','c','3.30'<<< ``` -Now `SELECT ... INTO @variable`, `SELECT ... INTO DUMPFILE` or any [external storage](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) like S3 or GCS is not supported. - ## MySQL compatibility - The syntax `SELECT ... INTO @variable` is not supported. +- The syntax `SELECT ... INTO DUMPFILE` is not supported. - The syntax `SELECT .. GROUP BY expr` does not imply `GROUP BY expr ORDER BY expr` as it does in MySQL 5.7. TiDB instead matches the behavior of MySQL 8.0 and does not imply a default order. - The syntax `SELECT ... TABLESAMPLE ...` is a TiDB extension and not supported by MySQL. From c0e09c37049e633337738c7ea461069dc818abd4 Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Tue, 31 Oct 2023 17:54:14 +0800 Subject: [PATCH 14/15] Update sql-statements/sql-statement-select.md Co-authored-by: Ran --- sql-statements/sql-statement-select.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index b36f355e8f392..1c93ac1d3c857 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -163,8 +163,7 @@ The `SELECT ... INTO OUTFILE` statement is used to write the result of a query t > **Note:** > > - This statement is only applicable to TiDB Self-Hosted and not available on [TiDB Cloud](https://docs.pingcap.com/tidbcloud/). -> - This statement does not support -writing query results to any [external storages](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) such as Amazon S3 or GCS. +> - This statement does not support writing query results to any [external storages](https://docs.pingcap.com/tidb/stable/backup-and-restore-storages) such as Amazon S3 or GCS. In the statement, you can specify the format of the output file by using the following clauses: From 4a096d489715cb027652e1f11cb5eec3bd140f1d Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Thu, 2 Nov 2023 15:55:44 +0800 Subject: [PATCH 15/15] Update sql-statements/sql-statement-select.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-select.md b/sql-statements/sql-statement-select.md index 1c93ac1d3c857..3c7a2321724f4 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -234,7 +234,7 @@ In this example, you can find the query result in `/tmp/tmp_file3` as follows: - The syntax `SELECT ... INTO @variable` is not supported. - The syntax `SELECT ... INTO DUMPFILE` is not supported. - The syntax `SELECT .. GROUP BY expr` does not imply `GROUP BY expr ORDER BY expr` as it does in MySQL 5.7. TiDB instead matches the behavior of MySQL 8.0 and does not imply a default order. -- The syntax `SELECT ... TABLESAMPLE ...` is a TiDB extension and not supported by MySQL. +- The syntax `SELECT ... TABLESAMPLE ...` is a TiDB extension designed for compatibility with other database systems and the [ISO/IEC 9075-2](https://standards.iso.org/iso-iec/9075/-2/ed-6/en/) standard, but currently it is not supported by MySQL. ## See also