I just create .sql files with all the commands I want to run and then run them in psql with the "\i myscript.sql".
If you want to switch databases in psql, use the \c[onnect] [DBNAME|- [USER]] . For example "\c my_database my_user".
I recommend going into psql and typing in "\?" for a list of common commands you can use.
-Aaron
On 6/6/06, Simon Dale < sdale@rm.com> wrote:Hi,
The CREATE TABLE command creates a table in the current database. What I want to achieve is a SQL script that will create a database and a user and then create some tables and functions in the new database.
Is it possible to do this in a single SQL file, and if so, how do I change the database part way through the file to create the tables in the correct database?