cheng
cheng

Reputation: 2136

Multiply statements run at one time in postgresql

In postgresql, if multiply SQL statements are executed at one time (In pgadmin, select all these statements and click "execute" button, like this picture), enter image description here
the server will wait until the last statement is done before the previous statements to take effect. When these statements are being executed, if I run SELECT * FROM tablename1 then the "relation not exist" error will occur.

Are there any ways for the statements to take effect once they are executed. Note: Every CREATE statement needs very short time if it is executed by itself. The SELECT statement needs a long time.

Upvotes: 1

Views: 4556

Answers (1)

vyegorov
vyegorov

Reputation: 22895

I assume, that when you select a bunch of statements in pgadmin and hit “Execute”, they all run in a single transaction. This means, that the results of the transaction will not be visible to the other concurrent sessions till it commits (or not visible at all if transaction fails).

Try adding explicit COMMIT; after each CREATE TABLE or after the last one.

You may also want to read about transaction isolation.

Upvotes: 3

Related Questions