Chapter 12. データベースの管理

Table of Contents
データベースの作成
データベースの代替領域
データベースへの接続
データベースの削除

Note: This section is currently a thinly disguised copy of the Tutorial. Needs to be augmented. - thomas 1998-01-12

この節はチュートリアルからのちょっとした借りうけです。 もっと増やす必要があります。

Although the site administrator is responsible for overall management of the Postgres installation, some databases within the installation may be managed by another person, designated the database administrator. This assignment of responsibilities occurs when a database is created. A user may be assigned explicit privileges to create databases and/or to create new users. A user assigned both privileges can perform most administrative task within Postgres, but will not by default have the same operating system privileges as the site administrator.

サイト管理者Postgres のインストール全般に渡って責任があるとはいっても、インストール内のいくつかの データベースはデータベース管理者と呼ばれる別の人に 管理をゆだねることが出来ます。 この責任の付与はデータベースが作成されたときに発生します。 あるユーザに、データベース作成を行なう権限とユーザ登録 を行なう権限を明示的に付与することができます。 両権現を持ったユーザは、Postgres 内で ほとんどの管理作業を行なうことができますが、デフォルトではサイト管理者 とは異なって、オペレーティングシステム上での同じような権限を持ちません。

The Database Administrator's Guide covers these topics in more detail.

管理者ガイドはこれらの話題についてより詳細に扱っています。

データベースの作成

Databases are created by the create database issued from within Postgres. createdb is a command-line utility provided to give the same functionality from outside Postgres.

データベースは Postgres 内から create database を発行することで作成されます。 createdb はコマンドラインユーティリティで Postgres 外部から同じ機能を提供するものです。

The Postgres backend must be running for either method to succeed, and the user issuing the command must be the Postgres superuser or have been assigned database creation privileges by the superuser.

どちらの方法もうまく行くためには Postgres バックエンドが走っていなければなりません。 そして、コマンドを発行するユーザは Postgres のスーパユーザかまたはスーパユーザにデータベース作成の権限を付与されていな ければなりません。

To create a new database named "mydb" from the command line, type

% createdb mydb
    
and to do the same from within psql type
* CREATE DATABASE mydb;
    

コマンドラインから "mydb" というデータベースを作成するには

% createdb mydb
    
のように入力し、psql からの場合は
* CREATE DATABASE mydb;
    
と入力します。

If you do not have the privileges required to create a database, you will see the following:

% createdb mydb
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
    

データベースを作成する権限がなかった場合は以下のメッセージが出ます。

% createdb mydb
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
    

Postgres allows you to create any number of databases at a given site and you automatically become the database administrator of the database you just created. Database names must have an alphabetic first character and are limited to 32 characters in length.

Postgres はある特定のサイトに おいて、いくつでもデータベースを作成することを許しており、 作成者は何もしなくても、いま作成したデータベースの管理者と なります。データベースは英文字で始まる 32 文字以内の名称に 限られます。