pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Creating a table in a different database
2+ messages / 2 participants
[nested] [flat]

* Creating a table in a different database
@ 2006-06-06 07:27  Simon Dale <sdale@rm.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Simon Dale @ 2006-06-06 07:27 UTC (permalink / raw)
  To: pgsql-admin

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?

 

Thanks,

 

Simon
______________________________________________________________________

You might be interested in this...

Professor Tim Brighouse describes the key features shared by successful schools in his new book - Download your copy now

http://www.rm.com/Generic.asp?cref=GP650420&Srcurl=ICS0505
______________________________________________________________________
 
Visit our Website at http://www.rm.com

This message is confidential. You should not copy it or disclose its contents to anyone. You may use and apply the information for the intended purpose only. Internet communications are not secure; therefore, RM does not accept legal responsibility for the contents of this message. Any views or opinions presented are those of the author only and not of RM. If this email has come to you in error, please delete it, along with any attachments. Please note that RM may intercept incoming and outgoing email communications. 

Freedom of Information Act 2000
This email and any attachments may contain confidential information belonging to RM.  Where the email and any attachments do contain information of a confidential nature, including without limitation information relating to trade secrets, special terms or prices these shall be deemed for the purpose of the Freedom of Information Act 2000 as information provided in confidence by RM and the disclosure of which would be prejudicial to RM's commercial interests.

This email has been scanned for viruses by Trend ScanMail.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Creating a table in a different database
@ 2006-06-06 08:57  Aaron Bono <postgresql@aranya.com>
  parent: Simon Dale <sdale@rm.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Aaron Bono @ 2006-06-06 08:57 UTC (permalink / raw)
  To: Simon Dale <sdale@rm.com>; +Cc: pgsql-admin

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?
>

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-06-06 08:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-06-06 07:27 Creating a table in a different database Simon Dale <sdale@rm.com>
2006-06-06 08:57 ` Aaron Bono <postgresql@aranya.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox