1

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.

2
  • «If the last SELECT statement needs a long time to run, the previous CREATE operations will not successfully create tables.» — do you have any evidence for this? And what you mean by «at one time and sequentially» — it is either in parallel or in order, as I see it. Commented Jun 21, 2012 at 8:48
  • @vyegorov I updated my question, sorry for the ambiguous. Commented Jun 21, 2012 at 9:01

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.