CREATE USER

Name

CREATE USER  --  Creates account information for a new user 新規ユーザのアカウント情報を作成する

Synopsis

CREATE USER username
    [ WITH PASSWORD password ]
    [ CREATEDB   | NOCREATEDB ]
    [ CREATEUSER | NOCREATEUSER ]
    [ IN GROUP     groupname [,
...] ]
    [ VALID UNTIL  'abstime' ]
  

入力

username

The name of the user.

ユーザ名

password

The WITH PASSWORD clause sets the user's password within the "pg_shadow" table. For this reason, "pg_shadow" is no longer accessible to the instance of Postgres that the Postgres user's password is initially set to NULL.

WITH PASSWORD 句は、ユーザパスワードを "pg_shadow" テーブルにセットします。 この理由のため、"pg_shadow" は Postgres ユーザのパスワードが 初期値として NULL値でセットされる Postgres のインスタンスに アクセスすることができなくなります。

When a user's password in the "pg_shadow" table is NULL, user authentication proceeds as it historically has (HBA, PG_PASSWORD, etc). However, if a password is set for a user, a new authentication system supplants any other configured for the Postgres instance, and the password stored in the "pg_shadow" table is used for authentication. For more details on how this authentication system functions see pg_crypt(3). If the WITH PASSWORD clause is omitted, the user's password is set to the empty string which equates to a NULL value in the authentication system mentioned above.

"pg_shadow" テーブルの中のユーザ パスワードが NULL 値である時、(HBA、PG_PASSWORDなどの) 従来通りのユーザ認証が行なわれます。ユーザにパスワードが 設定されている場合は、Postgres インスタンスに設定されている他の認証システムではなく、 新しい認証システムが使用されます。そして、 "pg_shadow"テーブル内のパスワードが 認証に使用されます。 この認証システムがどのように作用するかということの詳細は pg_crypt(3) を見てください。 もし WITH PASSWORD 句が省かれた 場合、ユーザのパスワードは上記に書かれた認証方式での NULL値 と同等に扱われる空白文字にセットされます。

CREATEDB, NOCREATEDB

These clauses define a user's ability to create databases. If CREATEDB is specified, the user being defined will be allowed to create his own databases. Using NOCREATEDB will deny a user the ability to create databases. If this clause is omitted, NOCREATEDB is used by default.

これらの句は、データベースを作成するユーザの能力を定義します。 もし CREATEDB が指定された場合、ユーザ所有のデータベースを 作成することが許されます。NOCREATEDBを使うことで、 データベースを作成する能力を与えません。もしこの句を省略した 場合、NOCREATEBD がデフォルトとして使用されます。

CREATEUSER, NOCREATEUSER

These clauses determine whether a user will be permitted to create new users in an instance of Postgres. Omitting this clause will set the user's value of this attribute to be NOCREATEUSER.

これらの句は、Postgres インスタンスの中で、ユーザが新たなユーザを作ることを許す かどうかを決定します。この句を省略した場合のユーザの アトリビュートには NOCREATEUSER がセットされます。

groupname

A name of a group into which to insert the user as a new member.

このユーザを新規メンバーとして入れたいグループ名

abstime

The VALID UNTIL clause sets an absolute time after which the user's Postgres login is no longer valid. Please note that if a user does not have a password defined in the "pg_shadow" table, the valid until date will not be checked during user authentication. If this clause is omitted, a NULL value is stored in "pg_shadow" for this attribute, and the login will be valid for all time.

VALID UNTIL 句は、ユーザの Postgres へのログインが有効では 無くなる絶対日時をセットします。 もし "pg_shadow" テーブルにユーザの パスワードが定義されてない場合、有効期限はユーザ認証の際には チェックされないということに注意してください。 もしこの句が省略された場合、 "pg_shadow" には NULL値が格納され、 ログインは永遠に有効になります。

出力

CREATE USER

Message returned if the command completes successfully.

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

説明

CREATE USER will add a new user to an instance of Postgres.

CREATE USER は、Postgres の インスタンスに、新しいユーザを加えます。

The new user will be given a usesysid of:

新しいユーザの usesysid には

SELECT MAX(usesysid) + 1 FROM pg_shadow;
   
が与えられます。 (訳注: pg_shadow テーブルにある usesysid の最大値に1を加えた もの。) This means that Postgres users' usesysids will not correspond to their operating system(OS) user ids. The exception to this rule is the postgres superuser, whose OS user id is used as the usesysid during the initdb process. If you still want the OS user id and the usesysid to match for any given user, use the createuser script provided with the Postgres distribution. これは、Postgres ユーザの usesysid が オペレーティングシステム(OS) のユーザ id と一致しないことを意味します。この規則の 例外は、postgres といわれるスーパユーザで、 OS のユーザ id が usesysid として initdb プロセスの間に使われます。 ユーザの OS ユーザ id とusesysidとを 一致させたい場合は、Postgres 配布物内にある createuser スクリプトを使用して下さい。

注意事項

CREATE USER statement is a Postgres language extension.

CREATE USER 文は、 Postgres の言語拡張です。

Use DROP USER or ALTER USER statements to remove or modify a user account.

ユーザアカウントの削除や変更には、 DROP USERALTER USER を使います。

Refer to the pg_shadow table for further information.

詳しくは、pg_shadow テーブルを参照 してください。

   Table    = pg_shadow
   +--------------------------+--------------------------+-------+
   |          Field           |          Type            | Length|
   +--------------------------+--------------------------+-------+
   | usename                  | name                     |    32 |
   | usesysid                 | int4                     |     4 |
   | usecreatedb              | bool                     |     1 |
   | usetrace                 | bool                     |     1 |
   | usesuper                 | bool                     |     1 |
   | usecatupd                | bool                     |     1 |
   | passwd                   | text                     |   var |
   | valuntil                 | abstime                  |     4 |
   +--------------------------+--------------------------+-------+
   

使用法

Create a user with no password:

パスワード無しでユーザを作成する:

CREATE USER jonathan
   

Create a user with a password:

パスワード付きでユーザを作成する:

CREATE USER davide WITH PASSWORD jw8s0F4
   

Create a user with a password, whose account is valid until the end of 2001. Note that after one second has ticked in 2002, the account is not valid:

2001年の終わりまで有効なアカウントを持ったパスワード付きユーザ を作成する。ただし、2002年に1秒でも入った後は、もうその アカウントは有効ではないことに注意:

CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'
   

Create an account where the user can create databases:

データベースを作成可能なユーザアカウントを作成する:

CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
   

互換性

SQL92

There is no CREATE USER statement in SQL92.

SQL92 には CREATE USER 文は有りません。