TiDB Data Export

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB数据导出

| username: liusu_sky

TiDB Version: 7.5.0
Question: After entering the database and editing the SQL, how can I export the query results to a specified file?
In MySQL, you can check the value of secure_file_priv, which is the default export path, by executing show global variables like ‘%secure%’;. However, executing this SQL in TiDB does not display secure_file_priv.

| username: Jasper | Original post link

If the data volume is small, you can directly use SELECT INTO OUTFILE.

If the data volume is large, it’s better to use Dumpling for export.

| username: liusu_sky | Original post link

I tested the export successfully. Is there any way to export it directly as an Excel spreadsheet?

| username: MrSylar | Original post link

Other available methods such as tee, backup, etc., depend on the export requirements.

| username: caiyfc | Original post link

Export to CSV and open with Excel.

| username: zhanggame1 | Original post link

Use a database tool to make it simpler.

| username: Kongdom | Original post link

:yum: I have to recommend the ETL tool Kettle again. In this situation, you probably need to rely on client functions or ETL tools.

| username: Kongdom | Original post link

Only two steps are needed to complete it. If you want to export and generate an Excel file in the application, it’s better to leave it to the developers to implement.

| username: liusu_sky | Original post link

Okay, I will study it, thank you.

| username: kelvin | Original post link

If the data volume is small, directly use SELECT INTO OUTFILE; if the data volume is large, use Dumpling.

| username: TiDBer_QKDdYGfz | Original post link

It feels quite useful when the data volume is small.

| username: Kongdom | Original post link

:flushed: It’s even better with large amounts of data. Especially with multi-threading support, it can be as fast as you need it to be.

| username: TiDBer_7S8XqKfl | Original post link

You can specify the export file extension as CSV, and then you can open it with Excel or WPS.

| username: 成为一名优秀的DBA | Original post link

Exporting in CSV format will do.

| username: jiayou64 | Original post link

SQL results cannot be directly imported, right? Try using a client like DBeaver.

| username: TiDBer_LM | Original post link

Kettle is indeed practical and essential for SQL and BI.

| username: zhaokede | Original post link

Kettle tool or have the developers write a dedicated export program.

| username: TiDBer_TQXaqJ6U | Original post link

Set the file extension to CSV format, it should be able to be opened with Excel.