dbeaver check sql for syntax without running

All we need is an easy explanation of the problem, so here it is.

Using the dbeaver tool, I want to check a script for syntax errors without actually running it.

For a long insert query (postgresql syntax, PostgreSQL 10.15) in the form of:

INSERT INTO schema1.table1
(t1_id, fk1_id, fk_2_id, col1, col2)
            -- etc, literally thousands of lines

I cannot run the prod-version of the query in a not-prod region, because the foreign keys are different.

So is there a way to just check the SQL’s syntax without running it. (It throws foreign key constraint errors in the not-prod region, so I ( that verifies the syntax, but I’d like to be doubly-sure.

As per comment below, I think for the case here (insert with foreign-key), a foreign-key-violation-error would verify the syntax, but there is still the general case: Is it possible to verify the syntax of the SQL query without actually running it? I would think that there are probably several cases that this would be useful.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

If you explain your query it is compiled but not executed. This means that it is checked for syntactic errors, but constraints are not validated against your data.

Note that constraints can influence the compiler though. In case you haven’t read it there is a nice article by Lucas Eder here that discusses this.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply