|
1 | | ---- |
2 | | -title: SHOW IMPORT JOB |
3 | | -summary: An overview of the usage of SHOW IMPORT JOB in TiDB. |
4 | | ---- |
5 | | - |
6 | | -# SHOW IMPORT JOB |
7 | | - |
8 | | -The `SHOW IMPORT JOB` statement is used to show `IMPORT` jobs created in TiDB. By default, `SHOW IMPORT JOBS` shows jobs created by the current user. To view all import jobs, you need the `SUPER` privilege. |
9 | | - |
10 | | -## Required privileges |
11 | | - |
12 | | -- `SHOW IMPORT JOBS`: if a user has the `SUPER` privilege, this statement shows all import jobs in TiDB. Otherwise, this statement only shows jobs created by the current user. |
13 | | -- `SHOW IMPORT JOB <job-id>`: only the creator of an import job or users with the `SUPER` privilege can use this statement to view a specific job. |
14 | | - |
15 | | -## Synopsis |
16 | | - |
17 | | -```ebnf+diagram |
18 | | -ShowImportJobsStmt ::= |
19 | | - 'SHOW' 'IMPORT' 'JOBS' ShowLikeOrWhereOpt? |
20 | | -
|
21 | | -ShowImportJobStmt ::= |
22 | | - 'SHOW' 'IMPORT' 'JOB' JobID |
23 | | -
|
24 | | -ShowLikeOrWhereOpt ::= |
25 | | - 'LIKE' SimpleExpr |
26 | | -| 'WHERE' Expression |
27 | | -``` |
28 | | - |
29 | | -The output fields of the `SHOW IMPORT JOB` statement are described as follows: |
30 | | - |
31 | | -| Column | Description | |
32 | | -|------------------|-------------------------| |
| 1 | +--- |
| 2 | +title: SHOW IMPORT JOB |
| 3 | +summary: An overview of the usage of SHOW IMPORT JOB in TiDB. |
| 4 | +--- |
| 5 | + |
| 6 | +# SHOW IMPORT JOB |
| 7 | + |
| 8 | +The `SHOW IMPORT JOB` statement is used to show `IMPORT` jobs created in TiDB. By default, `SHOW IMPORT JOBS` shows jobs created by the current user. To view all import jobs, you need the `SUPER` privilege. |
| 9 | + |
| 10 | +## Required privileges |
| 11 | + |
| 12 | +- `SHOW IMPORT JOBS`: if a user has the `SUPER` privilege, this statement shows all import jobs in TiDB. Otherwise, this statement only shows jobs created by the current user. |
| 13 | +The `SHOW IMPORT JOB` statement is used to show `IMPORT` jobs created in TiDB. |
| 14 | + |
| 15 | +It supports the following two forms: |
| 16 | + |
| 17 | +- `SHOW IMPORT JOBS` |
| 18 | +- `SHOW IMPORT JOB <job-id>` |
| 19 | + |
| 20 | +## Required privileges |
| 21 | + |
| 22 | +- `SHOW IMPORT JOBS`: by default, this statement only shows jobs created by the current user. To view all import jobs, you need the `SUPER` privilege. |
| 23 | +- `SHOW IMPORT JOB <job-id>`: only the creator of an import job or users with the `SUPER` privilege can use this statement to view a specific job. |
| 24 | + |
| 25 | +## Synopsis |
| 26 | + |
| 27 | +```ebnf+diagram |
| 28 | +ShowImportJobsStmt ::= |
| 29 | + 'SHOW' 'IMPORT' 'JOBS' ShowLikeOrWhereOpt? |
| 30 | +
|
| 31 | +ShowImportJobStmt ::= |
| 32 | + 'SHOW' 'IMPORT' 'JOB' JobID |
| 33 | +
|
| 34 | +ShowLikeOrWhereOpt ::= |
| 35 | + 'LIKE' SimpleExpr |
| 36 | +| 'WHERE' Expression |
| 37 | +``` |
| 38 | + |
| 39 | +The output fields of the `SHOW IMPORT JOB` statement are described as follows: |
| 40 | + |
| 41 | +| Column | Description | |
| 42 | +|------------------|-------------------------| |
33 | 43 | | Job_ID | The ID of the job | |
34 | 44 | | Group_Key | The group key of the job | |
35 | | -| Data_Source | Information about the data source | |
36 | | -| Target_Table | The name of the target table | |
37 | | -| Table_ID | The ID of the target table | |
38 | | -| Phase | The current phase of the job, including `importing`, `validating`, and `add-index` | |
39 | | -| Status | The current status of the job, including `pending` (means created but not started yet), `running`, `canceled`, `failed`, and `finished` | |
40 | | -| Source_File_Size | The size of the source file | |
41 | | -| Imported_Rows | The number of data rows that have been read and written to the target table | |
42 | | -| Result_Message | If the import fails, this field returns the error message. Otherwise, it is empty.| |
43 | | -| Create_Time | The time when the task is created | |
44 | | -| Start_Time | The time when the task is started | |
45 | | -| End_Time | The time when the task is ended | |
46 | | -| Created_By | The name of the database user who creates the task | |
| 45 | +| Data_Source | Information about the data source | |
| 46 | +| Target_Table | The name of the target table | |
| 47 | +| Table_ID | The ID of the target table | |
| 48 | +| Phase | The current phase of the job, including `importing`, `validating`, and `add-index` | |
| 49 | +| Status | The current status of the job, including `pending` (means created but not started yet), `running`, `canceled`, `failed`, and `finished` | |
| 50 | +| Source_File_Size | The size of the source file | |
| 51 | +| Imported_Rows | The number of data rows that have been read and written to the target table | |
| 52 | +| Result_Message | If the import fails, this field returns the error message. Otherwise, it is empty.| |
| 53 | +| Create_Time | The time when the task is created | |
| 54 | +| Start_Time | The time when the task is started | |
| 55 | +| End_Time | The time when the task is ended | |
| 56 | +| Created_By | The name of the database user who creates the task | |
47 | 57 | | Last_Update_Time | The time when the job was last updated | |
48 | | -| Cur_Step | The specific sequential processing step of this job | |
49 | | -| Cur_Step_Processed_Size | The amount of data that has been processed within the current step | |
50 | | -| Cur_Step_Total_Size | The total size of the data to be processed in the current step | |
51 | | -| Cur_Step_Progress_Pct | The estimated completion percentage of the current step | |
52 | | -| Cur_Step_Speed | The current data processing speed | |
53 | | -| Cur_Step_ETA | The estimated time remaining for the current step to complete | |
54 | | - |
55 | | -## Filtering import jobs |
56 | | - |
57 | | -Only `SHOW IMPORT JOBS` supports filtering import jobs with a `WHERE` or `LIKE` clause. `SHOW IMPORT JOB <job-id>` does not support these clauses. |
58 | | - |
59 | | -The `WHERE` clause can reference the output fields of `SHOW IMPORT JOBS`, including `Job_ID`, `Group_Key`, `Data_Source`, `Target_Table`, `Table_ID`, `Phase`, `Status`, `Source_File_Size`, `Imported_Rows`, `Result_Message`, `Create_Time`, `Start_Time`, `End_Time`, `Created_By`, `Last_Update_Time`, `Cur_Step`, `Cur_Step_Processed_Size`, `Cur_Step_Total_Size`, `Cur_Step_Progress_Pct`, `Cur_Step_Speed`, and `Cur_Step_ETA`. |
60 | | - |
61 | | -The `LIKE` clause matches its pattern only against the first column `Job_ID` (compared as a string). For example, `SHOW IMPORT JOBS LIKE '%1'` returns the jobs whose `Job_ID` ends with `1`. |
62 | | - |
63 | | -## Example |
64 | | - |
65 | | -Show all import jobs that the current user can view: |
66 | | - |
67 | | -```sql |
68 | | -SHOW IMPORT JOBS; |
69 | | -``` |
70 | | - |
71 | | -Show a specific import job by job ID: |
72 | | - |
73 | | -```sql |
74 | | -SHOW IMPORT JOB 2; |
75 | | -``` |
76 | | - |
77 | | -The output is as follows: |
78 | | - |
79 | | -| Job_ID | Group_Key | Data_Source | Target_Table | Table_ID | Phase | Status | Source_File_Size | Imported_Rows | Result_Message | Create_Time | Start_Time | End_Time | Created_By | Last_Update_Time | Cur_Step | Cur_Step_Processed_Size | Cur_Step_Total_Size | Cur_Step_Progress_Pct | Cur_Step_Speed | Cur_Step_ETA | |
80 | | -|--------|-----------|-------------|--------------|----------|-------|--------|------------------|---------------|----------------|-------------|------------|----------|------------|------------------|----------|-------------------------|---------------------|-----------------------|----------------|--------------| |
81 | | -| 2 | import_group_1 | /path/to/file.csv | `test`.`bar` | 118 | global-sorting | running | 277.5GiB | 0 | | 2025-07-09 10:40:18.580706 | 2025-07-09 10:40:19.092528 | NULL | root@% | 2025-07-09 10:47:15 | encode | 4.55GB | 298GB | 1 | 10.96MB/s | 07:26:03 | |
82 | | - |
83 | | -Filter import jobs by output fields: |
84 | | - |
85 | | -```sql |
86 | | -SHOW IMPORT JOBS WHERE Group_Key = 'user_group'; |
87 | | -``` |
88 | | - |
89 | | -## MySQL compatibility |
90 | | - |
91 | | -This statement is a TiDB extension to MySQL syntax. |
92 | | - |
93 | | -## See also |
94 | | - |
95 | | -* [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) |
96 | | -* [`SHOW IMPORT GROUP`](/sql-statements/sql-statement-show-import-group.md) |
97 | | -* [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md) |
| 58 | +| Cur_Step | The specific sequential processing step of this job | |
| 59 | +| Cur_Step_Processed_Size | The amount of data that has been processed within the current step | |
| 60 | +| Cur_Step_Total_Size | The total size of the data to be processed in the current step | |
| 61 | +| Cur_Step_Progress_Pct | The estimated completion percentage of the current step | |
| 62 | +| Cur_Step_Speed | The current data processing speed | |
| 63 | +| Cur_Step_ETA | The estimated time remaining for the current step to complete | |
| 64 | + |
| 65 | +## Filter import jobs |
| 66 | + |
| 67 | +Only `SHOW IMPORT JOBS` supports filtering import jobs with a `WHERE` or `LIKE` clause. `SHOW IMPORT JOB <job-id>` does not support these clauses. |
| 68 | + |
| 69 | +The `WHERE` clause can reference the output fields of `SHOW IMPORT JOBS`, including `Job_ID`, `Group_Key`, `Data_Source`, `Target_Table`, `Table_ID`, `Phase`, `Status`, `Source_File_Size`, `Imported_Rows`, `Result_Message`, `Create_Time`, `Start_Time`, `End_Time`, `Created_By`, `Last_Update_Time`, `Cur_Step`, `Cur_Step_Processed_Size`, `Cur_Step_Total_Size`, `Cur_Step_Progress_Pct`, `Cur_Step_Speed`, and `Cur_Step_ETA`. |
| 70 | + |
| 71 | +The `LIKE` clause matches its pattern only against the first column `Job_ID` (compared as a string). For example, `SHOW IMPORT JOBS LIKE '%1'` returns the jobs whose `Job_ID` ends with `1`. |
| 72 | + |
| 73 | +## Example |
| 74 | + |
| 75 | +Show all import jobs that the current user can view: |
| 76 | + |
| 77 | +```sql |
| 78 | +SHOW IMPORT JOBS; |
| 79 | +``` |
| 80 | + |
| 81 | +Show a specific import job by job ID: |
| 82 | + |
| 83 | +```sql |
| 84 | +SHOW IMPORT JOB 2; |
| 85 | +``` |
| 86 | + |
| 87 | +The output is as follows: |
| 88 | + |
| 89 | +| Job_ID | Group_Key | Data_Source | Target_Table | Table_ID | Phase | Status | Source_File_Size | Imported_Rows | Result_Message | Create_Time | Start_Time | End_Time | Created_By | Last_Update_Time | Cur_Step | Cur_Step_Processed_Size | Cur_Step_Total_Size | Cur_Step_Progress_Pct | Cur_Step_Speed | Cur_Step_ETA | |
| 90 | +|--------|-----------|-------------|--------------|----------|-------|--------|------------------|---------------|----------------|-------------|------------|----------|------------|------------------|----------|-------------------------|---------------------|-----------------------|----------------|--------------| |
| 91 | +| 2 | import_group_1 | /path/to/file.csv | `test`.`bar` | 118 | global-sorting | running | 277.5GiB | 0 | | 2025-07-09 10:40:18.580706 | 2025-07-09 10:40:19.092528 | NULL | root@% | 2025-07-09 10:47:15 | encode | 4.55GB | 298GB | 1 | 10.96MB/s | 07:26:03 | |
| 92 | + |
| 93 | +Filter import jobs by output fields: |
| 94 | + |
| 95 | +```sql |
| 96 | +SHOW IMPORT JOBS WHERE Group_Key = 'user_group'; |
| 97 | +``` |
| 98 | + |
| 99 | +## MySQL compatibility |
| 100 | + |
| 101 | +This statement is a TiDB extension to MySQL syntax. |
| 102 | + |
| 103 | +## See also |
| 104 | + |
| 105 | +* [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) |
| 106 | +* [`SHOW IMPORT GROUP`](/sql-statements/sql-statement-show-import-group.md) |
| 107 | +* [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md) |
0 commit comments