From d1355d0bb05153e44482f7f9bbb32c536b8a1072 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 63455b8ddd392..ef4b0c65bcebb 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -118,6 +118,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) @@ -159,6 +161,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 743cbebcae650ce0dd4a5bce9928bfe88dd6935e 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 ef4b0c65bcebb..bc9ca4f725624 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -216,7 +216,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 3372e665e8157d4a72418ec97c89f5a3a39a3bc9 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 bc9ca4f725624..ec0dd9e5a6f12 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -184,7 +184,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 edd989967c47121d1c08954dc0deb6f97e06237b 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 ec0dd9e5a6f12..535585e687dd5 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -163,7 +163,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 0b80b30261ea13c90265915837e7d331a4b839ab 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 535585e687dd5..e5177305da83e 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -163,9 +163,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 a6b83711ee67e591f7a0ea14f753e9525638fd6c 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 e5177305da83e..481daff5ca00f 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -179,7 +179,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 65e691d5ae1f4c9e9c8b7e1d970778e369a9d5a9 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 481daff5ca00f..07eeb10095721 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -189,6 +189,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 b8d2298f166fa7902cb2ee6edb30091700ec7a8a 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 07eeb10095721..ca4afd34406ff 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -172,12 +172,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 7454650268a828723e5a0ab96bf3e83065f4ce76 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 ca4afd34406ff..abc12e28d0035 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -208,7 +208,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 061c32e009fd77fc487d875d1a8c482492d9d33a 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 abc12e28d0035..5af7df567a5b9 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -197,7 +197,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 0c9f492c8bab9d3e4d6012f9af7d3ede8251b0a8 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 5af7df567a5b9..82828143a5d29 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -177,12 +177,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 447dd7fb5183577437e7521affd148f786a0205b 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 82828143a5d29..93c4841eca227 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -163,13 +163,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)); @@ -196,23 +196,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 7d7c073262c7ea463971cf8c374a7156de7248d9 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 93c4841eca227..54afefe130493 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -14,10 +14,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) @@ -163,11 +159,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: @@ -179,9 +183,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'; @@ -196,7 +200,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 '"'; @@ -211,7 +215,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' @@ -227,11 +231,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 49c3c571dc12c024ca2ae7ffcbd2a2e188a3c478 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 54afefe130493..c84aef5ecf906 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -164,8 +164,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 369b8871dfa4e3bf2dcfa68520e90652d94ce68c 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 c84aef5ecf906..8077af19dc5ae 100644 --- a/sql-statements/sql-statement-select.md +++ b/sql-statements/sql-statement-select.md @@ -235,7 +235,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