I am trying to write a script for the full creation of a database and all of its objects, similar to the following:
I'm running into a problem in that there doesn't appear to be a way to change the database connection mid-script. Do I just need to append the newly-created database name to all following CREATE TABLE commands (e.g. CREATE TABLE DBName.TableOne...)?
Secondly, is there a way to maintain the capitalization used in the table name in the CREATE TABLE command? If I execute CREATE TABLE TableOne, I get a table created named tableone.
Thanks.
Code:
CREATE DATABASE DBName;
\connect DBName;
CREATE TABLE TableOne
(
id BIGSERIAL NOT NULL PRIMARY KEY
, RowDesc VARCHAR(50)
);
Secondly, is there a way to maintain the capitalization used in the table name in the CREATE TABLE command? If I execute CREATE TABLE TableOne, I get a table created named tableone.
Thanks.