Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/createdb.sgml`
185c6b2cd3a191f485c77a512657f84f50fa953ba1fa688c0000000100000fa1
<!--
doc/src/sgml/ref/createdb.sgml
PostgreSQL documentation
-->

<refentry id="app-createdb">
 <indexterm zone="app-createdb">
  <primary>createdb</primary>
 </indexterm>

 <refmeta>
  <refentrytitle><application>createdb</application></refentrytitle>
  <manvolnum>1</manvolnum>
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>createdb</refname>
  <refpurpose>create a new <productname>PostgreSQL</productname> database</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
  <cmdsynopsis>
   <command>createdb</command>
   <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
   <arg rep="repeat"><replaceable>option</replaceable></arg>
   <arg choice="opt"><replaceable>dbname</replaceable>
   <arg choice="opt"><replaceable>description</replaceable></arg></arg>
  </cmdsynopsis>
 </refsynopsisdiv>


 <refsect1 id="r1-app-createdb-1">
  <title>Description</title>
  <para>
   <application>createdb</application> creates a new <productname>PostgreSQL</productname>
   database.
  </para>

  <para>
   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.
  </para>

  <para>
   <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.
  </para>

 </refsect1>


 <refsect1>
  <title>Options</title>

  <para>
   <application>createdb</application> accepts the following command-line arguments:

    <variablelist>
     <varlistentry>
      <term><replaceable class="parameter">dbname</replaceable></term>
      <listitem>
       <para>
        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.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">description</replaceable></term>
      <listitem>
       <para>
        Specifies a comment to be associated with the newly created
        database.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-D <replaceable class="parameter">tablespace</replaceable></option></term>
      <term><option>--tablespace=<replaceable class="parameter">tablespace</replaceable></option></term>
      <listitem>
       <para>
        Specifies the default tablespace for the database. (This name
        is processed as a double-quoted identifier.)
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-e</option></term>
      <term><option>--echo</option></term>
      <listitem>
       <para>
        Echo the commands that <application>createdb</application> generates
        and sends to the server.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
      <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
      <listitem>
       <para>
        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"/>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-l <replaceable class="parameter">locale</replaceable></option></term>
      <term><option>--locale=<replaceable class="parameter">locale</replaceable></option></term>
      <listitem>
       <para>

Title: createdb: Create a PostgreSQL Database
Summary
The `createdb` command is a utility for creating new PostgreSQL databases. It acts as a wrapper around the SQL command `CREATE DATABASE`. The user executing the command typically becomes the owner, but a different owner can be specified with appropriate privileges. The command accepts options to specify the database name, description, default tablespace, encoding, and locale.