CREATE DATABASE

Name

CREATE DATABASE  --  Creates a new database 新規にデータベースを作成する

Synopsis

CREATE DATABASE name [ WITH LOCATION = 'dbpath' ]
  

入力

name

The name of a database to create.

作成するデータベースの名前

dbpath

An alternate location can be specified as either an environment variable known to the backend server (e.g. 'PGDATA2') or as an absolute path name (e.g. '/usr/local/pgsql/data'). In either case, the location must be pre-configured by initlocation.

データベースを所定の場所以外に作成したいときは、バックエンド サーバが解釈できる環境変数(例えば 'PGDATA2') あるいは絶対パス(例えば'/usr/local/pgsql/data') で指定することができます。 どちらの場合でも、データベースを作成する場所をinitlocation コマンドで事前に設定しておく必要があります。

出力

CREATEDB

Message returned if the command completes successfully.

コマンドが正常に終了した場合に返されるメッセージです。

WARN: createdb: database "name" already exists.

This occurs if database specified already exists.

指定されたdatabase がすでに存在するときに このメッセージが返されます。

ERROR: Unable to create database directory directory

There was a problem with creating the required directory; this operation will need permissions for the postgres user on the specified location.

要求されたディレクトリを作成しようとしましたが問題が発生しました。この操作を行うには、 指定された場所に対してpostgres ユーザの権限がなくてはいけません。

説明

CREATE DATABASE creates a new Postgres database. The creator becomes the administrator of the new database.

CREATE DATABASE は、新規にPostgresデータベースを 作成します。この操作を行ったユーザが、作成したデータベースの管理者に なります。

注意

CREATE DATABASE is a Postgres language extension.

CREATE DATABASEPostgres独自の 拡張機能で、SQL標準の言語仕様には含まれていません。

Use DROP DATABASE to remove a database.

作成したデータベースを削除するときはDROP DATABASE を用います。

使用方法

To create a new database:

新規にデータベースを作成する方法:

   olly=> create database lusiadas;
   

To create a new database in an alternate area ~/private_db:

所定の場所とは別の場所~/private_dbに新規にデータベースを作成 する方法:

$ mkdir private_db
$ initlocation ~/private_db
Creating Postgres database system directory /home/olly/private_db/base
   
$ psql olly
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
    
    type \? for help on slash commands
    type \q to quit
    type \g or terminate with semicolon to execute query
    You are currently connected to the database: template1
    
olly=> create database elsewhere with location = '/home/olly/private_db';
CREATEDB
    

バグ情報

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.

所定の場所とは別の場所を絶対パスで指定してデータベースを 作成するとセキュリティおよびデータの整合性に問題が発生し ます。デフォルトでは、所定の場所と違う場所は、バックエンド サーバが解釈できる環境変数でのみ指定します。 詳細な情報を知りたい場合は管理者ガイドを参照してください。

互換性

SQL92

There is no CREATE DATABASE statement in SQL92.

SQL92にはCREATE DATABASEというコマンドは存在しません。

The equivalent command in standard SQL is CREATE SCHEMA.

SQL標準のCREATE SCHEMAコマンドに相当するものです。