-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-createdb.html
More file actions
311 lines (309 loc) · 27.1 KB
/
app-createdb.html
File metadata and controls
311 lines (309 loc) · 27.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>createdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-clusterdb.html" title="clusterdb" /><link rel="next" href="app-createuser.html" title="createuser" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body id="docContent" class="container-fluid col-10"><div class="other_version"><a href="https://www.postgresql.jp/document/">バージョンごとのドキュメント一覧</a></div><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 18.3文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="reference-client.html" title="PostgreSQLクライアントアプリケーション">PostgreSQLクライアントアプリケーション</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?template=bug_report.yml&what-happened=version 18.3 : app-createdb.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-clusterdb.html" title="clusterdb">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQLクライアントアプリケーション">上へ</a></td><td width="60%" align="center"><span class="application">createdb</span></td><td width="20%" align="right"> <a accesskey="n" href="app-createuser.html" title="createuser">次へ</a></td></tr></table><hr /></div><div class="refentry" id="APP-CREATEDB"><div class="titlepage"></div><a id="id-1.9.4.4.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">createdb</span></span></h2><p>createdb<span class="original">
<refpurpose>create a new <productname>PostgreSQL</productname> database</refpurpose>
</span> — 新しい<span class="productname">PostgreSQL</span>データベースを作成する</p></div><div class="refsynopsisdiv"><h2>概要</h2><div class="cmdsynopsis"><p id="id-1.9.4.4.4.1"><code class="command">createdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>
[<em class="replaceable"><code>description</code></em>]]</p></div></div><div class="refsect1" id="R1-APP-CREATEDB-1"><h2>説明</h2><span class="original">
<title>Description</title>
</span><p>
<span class="original">
<application>createdb</application> creates a new <productname>PostgreSQL</productname>
database.
</span>
<span class="application">createdb</span>は、新しい<span class="productname">PostgreSQL</span>データベースを作成します。
</p><p>
<span class="original">
Normally, the database user who executes this command becomes the owner of
the new database.
However, a different owner can be specified via the <option>-O</option>
option, if the executing user has appropriate privileges.
</span>
通常、このコマンドを実行したデータベースユーザが、新しいデータベースの所有者になります。
ただし、コマンドを実行するユーザが適切な権限を持っている場合、<code class="option">-O</code>オプションを使用して別のユーザを所有者に指定できます。
</p><p>
<span class="original">
<application>createdb</application> is a wrapper around the
<acronym>SQL</acronym> command <link linkend="sql-createdatabase"><command>CREATE DATABASE</command></link>.
There is no effective difference between creating databases via
this utility and via other methods for accessing the server.
</span>
<span class="application">createdb</span>は<a class="link" href="sql-createdatabase.html" title="CREATE DATABASE"><code class="command">CREATE DATABASE</code></a>という<acronym class="acronym">SQL</acronym>コマンドのラッパーです。
したがって、このユーティリティでデータベースを作成しても、これ以外の方法でサーバにアクセスしてデータベースを作成しても何も違いはありません。
</p></div><div class="refsect1" id="id-1.9.4.4.6"><h2>オプション</h2><span class="original">
<title>Options</title>
</span><p>
<span class="original">
<application>createdb</application> accepts the following command-line arguments:
</span>
<span class="application">createdb</span>では、下記のコマンドライン引数を指定できます。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>
<span class="original">
Specifies the name of the database to be created. The name must be
unique among all <productname>PostgreSQL</productname> databases in this cluster.
The default is to create a database with the same name as the
current system user.
</span>
作成するデータベースの名前を指定します。
この名前はクラスタ内の全ての<span class="productname">PostgreSQL</span>データベースの中で一意でなければなりません。
デフォルトでは、現在のシステムユーザと同じ名前でデータベースを作成します。
</p></dd><dt><span class="term"><em class="replaceable"><code>description</code></em></span></dt><dd><p>
<span class="original">
Specifies a comment to be associated with the newly created
database.
</span>
新しく作成されるデータベースに関連付けるコメントを指定します。
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>tablespace</code></em></code><br /></span><span class="term"><code class="option">--tablespace=<em class="replaceable"><code>tablespace</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the default tablespace for the database. (This name
is processed as a double-quoted identifier.)
</span>
データベース用のデフォルトのテーブル空間を指定します。
(この名前は二重引用符で囲まれた識別子として処理されます。)
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>
<span class="original">
Echo the commands that <application>createdb</application> generates
and sends to the server.
</span>
<span class="application">createdb</span>が生成し、サーバに送信するコマンドをエコー表示します。
</p></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the character encoding scheme to be used in this
database. The character sets supported by the
<productname>PostgreSQL</productname> server are described in
<xref linkend="multibyte-charset-supported"/>.
</span>
このデータベース内で使用する文字符号化方式を指定します。
<span class="productname">PostgreSQL</span>サーバでサポートされる文字集合については<a class="xref" href="multibyte.html#MULTIBYTE-CHARSET-SUPPORTED" title="23.3.1. サポートされる文字集合">23.3.1</a>で説明します。
</p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--locale=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the locale to be used in this database. This is equivalent
to specifying <option>&#45;-lc-collate</option>,
<option>&#45;-lc-ctype</option>, and <option>&#45;-icu-locale</option> to the
same value. Some locales are only valid for ICU and must be set with
<option>&#45;-icu-locale</option>.
</span>
このデータベースで使用されるロケールを指定します。
これは、<code class="option">--lc-collate</code>、<code class="option">--lc-ctype</code>、および<code class="option">--icu-locale</code>を同じ値に指定することと等価です。
一部のロケールはICUに対してのみ有効であり、<code class="option">--icu-locale</code>で設定することが必要です。
</p></dd><dt><span class="term"><code class="option">--lc-collate=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the LC_COLLATE setting to be used in this database.
</span>
このデータベースで使用されるLC_COLLATE設定を指定します。
</p></dd><dt><span class="term"><code class="option">--lc-ctype=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the LC_CTYPE setting to be used in this database.
</span>
このデータベースで使用されるLC_CTYPE設定を指定します。
</p></dd><dt><span class="term"><code class="option">--builtin-locale=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the locale name when the builtin provider is used. Locale support
is described in <xref linkend="locale"/>.
</span>
組み込みプロバイダを使用する場合にロケール名を指定します。
ロケールのサポートについては<a class="xref" href="locale.html" title="23.1. ロケールのサポート">23.1</a>で説明します。
</p></dd><dt><span class="term"><code class="option">--icu-locale=<em class="replaceable"><code>locale</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the ICU locale ID to be used in this database, if the
ICU locale provider is selected.
</span>
ICUロケールプロバイダを選択した場合に、このデータベースで使用されるICUロケールIDを指定します。
</p></dd><dt><span class="term"><code class="option">--icu-rules=<em class="replaceable"><code>rules</code></em></code></span></dt><dd><p>
<span class="original">
Specifies additional collation rules to customize the behavior of the
default collation of this database. This is supported for ICU only.
</span>
このデータベースのデフォルトの照合の動作をカスタマイズするための追加の照合規則を指定します。
これはICUのみでサポートされています。
</p></dd><dt><span class="term"><code class="option">--locale-provider={<code class="literal">builtin</code>|<code class="literal">libc</code>|<code class="literal">icu</code>}</code></span></dt><dd><p>
<span class="original">
Specifies the locale provider for the database's default collation.
</span>
データベースのデフォルトの照合順序のロケールプロバイダを指定します。
</p></dd><dt><span class="term"><code class="option">-O <em class="replaceable"><code>owner</code></em></code><br /></span><span class="term"><code class="option">--owner=<em class="replaceable"><code>owner</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the database user who will own the new database.
(This name is processed as a double-quoted identifier.)
</span>
新しいデータベースの所有者となるデータベースユーザを指定します。
(この名前は二重引用符で囲まれた識別子として処理されます。)
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>strategy</code></em></code><br /></span><span class="term"><code class="option">--strategy=<em class="replaceable"><code>strategy</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the database creation strategy. See
<xref linkend="create-database-strategy" /> for more details.
</span>
データベース作成手法を指定します。
詳細は<a class="xref" href="sql-createdatabase.html#CREATE-DATABASE-STRATEGY">CREATE DATABASE STRATEGY</a>を参照してください。
</p></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>template</code></em></code><br /></span><span class="term"><code class="option">--template=<em class="replaceable"><code>template</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the template database from which to build this
database. (This name is processed as a double-quoted identifier.)
</span>
このデータベースの構築に使用するテンプレートデータベースを指定します。
(この名前は二重引用符で囲まれた識別子として処理されます。)
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
<span class="original">
Print the <application>createdb</application> version and exit.
</span>
<span class="application">createdb</span>のバージョンを表示し、終了します。
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
<span class="original">
Show help about <application>createdb</application> command line
arguments, and exit.
</span>
<span class="application">createdb</span>のコマンドライン引数の使用方法を表示し、終了します。
</p></dd></dl></div><p>
</p><p>
<span class="original">
The options <option>-D</option>, <option>-l</option>, <option>-E</option>,
<option>-O</option>, and
<option>-T</option> correspond to options of the underlying
SQL command <link linkend="sql-createdatabase"><command>CREATE DATABASE</command></link>; see there for more information
about them.
</span>
オプション<code class="option">-D</code>、<code class="option">-l</code>、<code class="option">-E</code>、<code class="option">-O</code>、および<code class="option">-T</code>は、基盤となる<a class="link" href="sql-createdatabase.html" title="CREATE DATABASE"><code class="command">CREATE DATABASE</code></a>というSQLコマンドのオプションにそれぞれ対応しています。
詳細はそちらを参照してください。
</p><p>
<span class="original">
<application>createdb</application> also accepts the following
command-line arguments for connection parameters:
</span>
また<span class="application">createdb</span>は、以下のコマンドライン引数を接続パラメータとして受け付けます。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the host name of the machine on which the
server is running. If the value begins with a slash, it is used
as the directory for the Unix domain socket.
</span>
サーバが稼働しているマシンのホスト名を指定します。
この値がスラッシュから始まる場合、Unixドメインソケット用のディレクトリとして使用されます。
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the TCP port or the local Unix domain socket file
extension on which the server is listening for connections.
</span>
サーバが接続を監視するTCPポートもしくはUnixドメインソケットのファイル拡張子を指定します。
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
<span class="original">
User name to connect as.
</span>
接続に使用するユーザ名を指定します。
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
<span class="original">
Never issue a password prompt. If the server requires
password authentication and a password is not available by
other means such as a <filename>.pgpass</filename> file, the
connection attempt will fail. This option can be useful in
batch jobs and scripts where no user is present to enter a
password.
</span>
パスワードの入力を促しません。
サーバがパスワード認証を必要とし、かつ、<code class="filename">.pgpass</code>ファイルなどの他の方法が利用できない場合、接続試行は失敗します。
バッチジョブやスクリプトなどパスワードを入力するユーザが存在しない場合にこのオプションは有用かもしれません。
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
<span class="original">
Force <application>createdb</application> to prompt for a
password before connecting to a database.
</span>
データベースに接続する前に、<span class="application">createdb</span>は強制的にパスワード入力を促します。
</p><p>
<span class="original">
This option is never essential, since
<application>createdb</application> will automatically prompt
for a password if the server demands password authentication.
However, <application>createdb</application> will waste a
connection attempt finding out that the server wants a password.
In some cases it is worth typing <option>-W</option> to avoid the extra
connection attempt.
</span>
サーバがパスワード認証を要求する場合<span class="application">createdb</span>は自動的にパスワード入力を促しますので、これが重要になることはありません。
しかし、<span class="application">createdb</span>は、サーバにパスワードが必要かどうかを判断するための接続試行を無駄に行います。
こうした余計な接続試行を防ぐために<code class="option">-W</code>の入力が有意となる場合もあります。
</p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the name of the database to connect to when creating the
new database. If not specified, the <literal>postgres</literal>
database will be used; if that does not exist (or if it is the name
of the new database being created), <literal>template1</literal> will
be used.
This can be a <link linkend="libpq-connstring">connection
string</link>. If so, connection string parameters will override any
conflicting command line options.
</span>
新しいデータベースを作成する時の接続先となるデータベースの名前を指定します。
指定がなければ、<code class="literal">postgres</code>データベースが使用されます。
もし存在しなければ(またはこれが作成しようとしているデータベースの名前であれば)<code class="literal">template1</code>が使用されます。
これは<a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="32.1.1. 接続文字列">接続文字列</a>でも構いません。
その場合、接続文字列パラメータは衝突するコマンドラインオプションよりも優先します。
</p></dd></dl></div><p>
</p></div><div class="refsect1" id="id-1.9.4.4.7"><h2>環境</h2><span class="original">
<title>Environment</title>
</span><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGDATABASE</code></span></dt><dd><p>
<span class="original">
If set, the name of the database to create, unless overridden on
the command line.
</span>
この値が設定されている場合、コマンドラインで上書きされなければ、設定された値が作成するデータベースの名前になります。
</p></dd><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
<span class="original">
Default connection parameters. <envar>PGUSER</envar> also
determines the name of the database to create, if it is not
specified on the command line or by <envar>PGDATABASE</envar>.
</span>
デフォルトの接続パラメータです。
コマンドラインでも<code class="envar">PGDATABASE</code>でも名前が指定されていない場合は、<code class="envar">PGUSER</code>が作成するデータベースの名前にもなります。
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
<span class="original">
Specifies whether to use color in diagnostic messages. Possible values
are <literal>always</literal>, <literal>auto</literal> and
<literal>never</literal>.
</span>
診断メッセージで色を使うかどうかを指定します。
指定可能な値は<code class="literal">always</code>、<code class="literal">auto</code>、<code class="literal">never</code>です。
</p></dd></dl></div><p>
<span class="original">
This utility, like most other <productname>PostgreSQL</productname> utilities,
also uses the environment variables supported by <application>libpq</application>
(see <xref linkend="libpq-envars"/>).
</span>
このユーティリティは、他のほとんどの<span class="productname">PostgreSQL</span>ユーティリティと同様、<span class="application">libpq</span>がサポートする環境変数(<a class="xref" href="libpq-envars.html" title="32.15. 環境変数">32.15</a>参照)も使います。
</p></div><div class="refsect1" id="id-1.9.4.4.8"><h2>診断</h2><span class="original">
<title>Diagnostics</title>
</span><p>
<span class="original">
In case of difficulty, see <xref linkend="sql-createdatabase"/>
and <xref linkend="app-psql"/> for
discussions of potential problems and error messages.
The database server must be running at the
targeted host. Also, any default connection settings and environment
variables used by the <application>libpq</application> front-end
library will apply.
</span>
問題が発生した場合、考えられる原因とエラーメッセージの説明について<a class="xref" href="sql-createdatabase.html" title="CREATE DATABASE"><span class="refentrytitle">CREATE DATABASE</span></a>と<a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a>を参照してください。
データベースサーバは対象ホストで稼働していなければなりません。
また、<span class="application">libpq</span>フロントエンドライブラリで使用される、全てのデフォルトの接続設定と環境変数が適用されることも覚えておいてください。
</p></div><div class="refsect1" id="id-1.9.4.4.9"><h2>例</h2><span class="original">
<title>Examples</title>
</span><p>
<span class="original">
To create the database <literal>demo</literal> using the default
database server:
</span>
デフォルトのデータベースサーバを使用して<code class="literal">demo</code>データベースを作成します。
</p><pre class="screen">
<code class="prompt">$ </code><strong class="userinput"><code>createdb demo</code></strong>
</pre><p>
</p><p>
<span class="original">
To create the database <literal>demo</literal> using the
server on host <literal>eden</literal>, port 5000, using the
<literal>template0</literal> template database, here is the
command-line command and the underlying SQL command:
</span>
<code class="literal">eden</code>ホスト上のポート番号5000のサーバを使用し、<code class="literal">template0</code>テンプレートデータベースを使用して<code class="literal">demo</code>データベースを作成する場合の、コマンドラインから入力するコマンドと背後で実行されるSQLコマンドを示します。
</p><pre class="screen">
<code class="prompt">$ </code><strong class="userinput"><code>createdb -p 5000 -h eden -T template0 -e demo</code></strong>
<code class="computeroutput">CREATE DATABASE demo TEMPLATE template0;</code>
</pre></div><div class="refsect1" id="id-1.9.4.4.10"><h2>関連項目</h2><span class="original">
<title>See Also</title>
</span><span class="simplelist"><a class="xref" href="app-dropdb.html" title="dropdb"><span class="refentrytitle"><span class="application">dropdb</span></span></a>, <a class="xref" href="sql-createdatabase.html" title="CREATE DATABASE"><span class="refentrytitle">CREATE DATABASE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-clusterdb.html" title="clusterdb">前へ</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQLクライアントアプリケーション">上へ</a></td><td width="40%" align="right"> <a accesskey="n" href="app-createuser.html" title="createuser">次へ</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">clusterdb</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.3文書">ホーム</a></td><td width="40%" align="right" valign="top"> <span class="application">createuser</span></td></tr></table></div></body></html>