Обсуждение: Creating a table in a different database
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
Visit our Website at 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.
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
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?