Prerequisite: There are three tables in total, Table 1 and Table 2 and Table 3
The requirement is to query the query results of Table 1 and Table 2 and Table 3.
So I wrote sql as follows
CREATE TEMPORARY TABLE temp_reports AS SELECT gr.*, sd.dept_id, sd.parent_id FROM pc_amount_report gr LEFT JOIN sys_dept sd ON gr.comp_id = sd.dept_id WHERE gr.report_year = 2022 AND gr.report_month = 5 AND ( sd.dept_id = ( SELECT dept_id FROM sys_dept WHERE dept_name = 'So-so ) OR sd.parent_id = ( SELECT dept_id FROM sys_dept WHERE dept_name = 'So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So-So ) );
SELECT pt.* FROM pc_amount_report_task pt LEFT JOIN temp_reports tr ON pt.pc_amount_report_task_id = tr.pc_amount_report_task_id AND pt.plan_id = tr.plan_id and pt.approval_company_code=tr.approval_company_code and pt.approval_company_name=tr.approval_company_name and pt.report_year=tr.report_year
However, after the execution, use select * from temporary table temp_reports to investigate and deal with the incoming data, and then search for the table name in the database search box but it cannot be searched out, so the second paragraph of SQL cannot be executed.
Finally, I found that I didn't have permission to create tables, which was speechless
If you are like me and cannot execute SQL, you can refer to the following reasons for troubleshooting
Error message "already exists" usually means that the temporary table you are trying to create already exists in the database.
Solution:
- Check table name: Make sure that the temporary table name you entered is unique and does not conflict with the existing table name in the database.
- Check sessions: If you perform a creation operation in a different database session, make sure you look up tables in the correct session.
- Clean the session: If you confirm that the table name is not problem, try cleaning the current database session and recreating the temporary table.
- Permissions issue: Confirm that you have sufficient permissions to create temporary tables in the database.
- Syntax check: Confirm that the SQL statement syntax is correct, and there are no keywords or incorrect syntax structures.
If you confirm that the temporary table does not exist but still receive an error message, you can try the following steps:
- Refresh the database view.
- Restart database management tools (such as DBeaver).
- Restart the database service.
If none of these steps resolve the issue, you may need to contact the database administrator or view the database log for more information.
This is the article about the problem troubleshooting after creating a create temporary table by dbeaver. For more information about creating a create temporary table by dbeaver, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!