Ariel Grabijas
Ariel Grabijas

Reputation: 1512

Create database, tables etc in one script postgresql

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?

Upvotes: 15

Views: 27584

Answers (1)

John Woo
John Woo

Reputation: 263913

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); 

Upvotes: 23

Related Questions