Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've a script:

CREATE DATABASE ahop

GO

CREATE TABLE shop.dbo.TABLE1 ( 
); 

CREATE TABLE shop.dbo.TABLEN ( 
); 

But it doesn't seem to work in PostgreSQL. Error message: "error near GO". I dont get it, how to create scripts in Postgresql?

share|improve this question
 
When i remove "GO" and replace it by ";" I've got an error. Message: "CREATE DATABASE cannot be executed from a function or multi-command string". And the issue is, that i need to execute them all from one script. –  Noran Nov 25 '12 at 16:12
 
You also can't specify a table with database.schema.tablename. But this all documented in the manual. –  a_horse_with_no_name Nov 25 '12 at 16:18
 
the one you showed is for TSQL –  今 草 顿 웃 Nov 25 '12 at 16:19
add comment

1 Answer

up vote 2 down vote accepted

Replace the T-SQL batch terminator GO with the PostgreSQL batch terminator ;.
GO is not supported in postgreSQL

you need to connect on the database using \. eg,

 CREATE DATABASE testdatabase; 
 \c testdatabase 
 CREATE TABLE testtable (testcolumn int); 
share|improve this answer
 
Please take a look on my comment to main post. –  Noran Nov 25 '12 at 16:14
 
see my updated answer. –  今 草 顿 웃 Nov 25 '12 at 16:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.