|
CREATE DATABASENameCREATE DATABASE — Creates a new databaseCREATE DATABASE name [ WITH LOCATION = 'dbpath' ] Inputs
Outputs
DescriptionCREATE DATABASE creates a new Postgres database. The creator becomes the owner of the new database. An alternate location can be specified in order to, for example, store the database on a different disk. The path must have been prepared with the initlocation command. If the path contains a slash, the leading part is interpreted as an environment variable, which must be known to the server process. This way the database administrator can exercise control over at which locations databases can be created. (A customary choice is, e.g., 'PGDATA2'.) If the server is compiled with ALLOW_ABSOLUTE_DBPATHS (not so by default), absolute path names, as identified by a leading slash (e.g. '/usr/local/pgsql/data'), are allowed as well. NotesCREATE DATABASE is a Postgres language extension. Use DROP DATABASE to remove a database. The program createdb is a shell script wrapper around this command, provided for convenience. There are security and data integrity issues involved with using alternate database locations specified with absolute path names, and by default only an environment variable known to the backend may be specified for an alternate location. See the Administrator's Guide for more information. UsageTo create a new database: olly=> create database lusiadas; To create a new database in an alternate area ~/private_db: $ mkdir private_db $ initlocation ~/private_db Creating Postgres database system directory /home/olly/private_db/base $ psql olly Welcome to psql, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit olly=> CREATE DATABASE elsewhere WITH LOCATION = '/home/olly/private_db'; CREATE DATABASE CompatibilitySQL92There is no CREATE DATABASE statement in SQL92. Databases are equivalent to catalogs whose creation is implementation-defined. |
|||||||||||||||||
With any suggestions or questions please feel free to contact us |