create_database.sgml
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:6k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1. <refentry id="SQL-CREATEDATABASE">
  2.  <refmeta>
  3.   <refentrytitle>
  4.    CREATE DATABASE
  5.   </refentrytitle>
  6.   <refmiscinfo>SQL - Language Statements</refmiscinfo>
  7.  </refmeta>
  8.  <refnamediv>
  9.   <refname>
  10.    CREATE DATABASE
  11.   </refname>
  12.   <refpurpose>
  13.    Creates a new database
  14.   </refpurpose>
  15.  </refnamediv>
  16.  <refsynopsisdiv>
  17.   <refsynopsisdivinfo>
  18.    <date>1998-04-15</date>
  19.   </refsynopsisdivinfo>
  20.   <synopsis>
  21. CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>' ]
  22.   </synopsis>
  23.   <refsect2 id="R2-SQL-CREATEDATABASE-1">
  24.    <refsect2info>
  25.     <date>1998-04-15</date>
  26.    </refsect2info>
  27.    <title>
  28.     Inputs
  29.    </title>
  30.    <para>
  31.     <variablelist>
  32.      <varlistentry>
  33.       <term><replaceable class="parameter">name</replaceable></term>
  34.       <listitem>
  35.        <para>
  36. The name of a database to create.
  37.        </para>
  38.       </listitem>
  39.      </varlistentry>
  40.      <varlistentry>
  41.       <term><replaceable class="parameter">dbpath</replaceable></term>
  42.       <listitem>
  43.        <para>
  44. An alternate location can be specified as either an
  45. environment variable known to the backend server
  46. (e.g. '<envar>PGDATA2</envar>') or as an absolute path name
  47. (e.g. '<filename>/usr/local/pgsql/data</filename>').
  48. In either case, the location must be pre-configured
  49. by <command>initlocation</command>.
  50.        </para>
  51.       </listitem>
  52.      </varlistentry>
  53.     </variablelist>
  54.    </para>
  55.   </refsect2>
  56.   <refsect2 id="R2-SQL-CREATEDATABASE-2">
  57.    <refsect2info>
  58.     <date>1998-04-15</date>
  59.    </refsect2info>
  60.    <title>
  61.     Outputs
  62.    </title>
  63.    <para>
  64.     <variablelist>
  65.      <varlistentry>
  66.       <term><computeroutput>
  67. CREATEDB
  68.        </computeroutput></term>
  69.       <listitem>
  70.        <para>
  71. Message returned if the command completes successfully.
  72.        </para>
  73.       </listitem>
  74.      </varlistentry>
  75.      <varlistentry>
  76.       <term><computeroutput>
  77. WARN:  createdb: database "<replaceable class="parameter">name</replaceable>" already exists.
  78.        </computeroutput></term>
  79.       <listitem>
  80.        <para>
  81. This occurs if <replaceable class="parameter">database</replaceable> specified already exists.
  82.        </para>
  83.       </listitem>
  84.      </varlistentry>
  85.      <varlistentry>
  86.       <term><computeroutput>
  87. ERROR:  Unable to create database directory <replaceable class="parameter">directory</replaceable>
  88.        </computeroutput></term>
  89.       <listitem>
  90.        <para>
  91. There was a problem with creating the required directory; this operation will
  92. need permissions for the <literal>postgres</literal> user on the specified location.
  93.        </para>
  94.       </listitem>
  95.      </varlistentry>
  96.     </variablelist>
  97.    </para>
  98.   </refsect2>
  99.  </refsynopsisdiv>
  100.  <refsect1 id="R1-SQL-CREATEDATABASE-1">
  101.   <refsect1info>
  102.    <date>1998-04-15</date>
  103.   </refsect1info>
  104.   <title>
  105.    Description
  106.   </title>
  107.   <para>
  108.    <command>CREATE DATABASE</command> creates a new Postgres database.
  109.    The creator becomes the administrator of the new database.
  110.   </para>
  111.   <refsect2 id="R2-SQL-CREATEDATABASE-3">
  112.    <refsect2info>
  113.     <date>1998-04-15</date>
  114.    </refsect2info>
  115.    <title>
  116.     Notes
  117.    </title>
  118.    <para>
  119.     <command>CREATE DATABASE</command> is a <productname>Postgres</productname>
  120.     language extension.
  121.    </para>
  122.    <para>
  123.     Use <command>DROP DATABASE</command> to remove a database.
  124.    </para>
  125.   </refsect2>
  126.  </refsect1>
  127.  <refsect1 id="R1-SQL-CREATEDATABASE-2">
  128.   <title>
  129.    Usage
  130.   </title>
  131.   <para>
  132.    To create a new database:
  133.    <programlisting>
  134. <prompt>olly=></prompt> <userinput>create database lusiadas;</userinput>
  135.    </programlisting>
  136.   </para>
  137.   <para>
  138.    To create a new database in an alternate area <filename>~/private_db</filename>:
  139.    <programlisting>
  140. <prompt>$</prompt> <userinput>mkdir private_db</userinput>
  141. <prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
  142. <computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
  143.    
  144.    <prompt>$</prompt> <userinput>psql olly</userinput>
  145.    <computeroutput>Welcome to the POSTGRESQL interactive sql monitor:
  146.     Please read the file COPYRIGHT for copyright terms of POSTGRESQL
  147.     
  148.     type ? for help on slash commands
  149.     type q to quit
  150.     type g or terminate with semicolon to execute query
  151.     You are currently connected to the database: template1
  152.     
  153.     <prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
  154.    <computeroutput>CREATEDB</computeroutput>
  155.    </programlisting>
  156.   </para>
  157.  </refsect1>
  158.  <refsect1 id="R1-SQL-CREATEDATABASE-3">
  159.   <title>
  160.    Bugs
  161.   </title>
  162.   <para>
  163.    There are security and data integrity issues
  164.    involved with using alternate database locations
  165.    specified with absolute path names, and by default
  166.    only an environment variable known to the backend may be
  167.    specified for an alternate location.
  168.    See the Administrator's Guide for more information.
  169.   </para>
  170.  </refsect1>
  171. <!--
  172. comment from Olly; response from Thomas...
  173.   <comment>
  174.    initlocation does not create a PG_VERSION file in the specified location.
  175.    How will Postgres handle the situation if it is upgraded to an 
  176.    incompatible database version?
  177.   </comment>
  178. Hmm. This isn't an issue since the upgrade would do a dump/reload from the main database area also.
  179. Not sure if the dump/reload would guarantee that the alternate data area gets refreshed though...
  180. -->
  181.  
  182.  <refsect1 id="R1-SQL-CREATEDATABASE-4">
  183.   <title>
  184.    Compatibility
  185.   </title>
  186.   <refsect2 id="R2-SQL-CREATEDATABASE-4">
  187.    <refsect2info>
  188.     <date>1998-04-15</date>
  189.    </refsect2info>
  190.    <title>
  191.     SQL92
  192.    </title>
  193.    <para>
  194.     There is no <command>CREATE DATABASE</command> statement in SQL92.
  195.    </para>
  196.    <para>
  197.     The equivalent command in standard SQL is <command>CREATE SCHEMA</command>.
  198.    </para>
  199.   </refsect2>
  200.  </refsect1>
  201. </refentry>
  202. <!-- Keep this comment at the end of the file
  203. Local variables:
  204. mode: sgml
  205. sgml-omittag:nil
  206. sgml-shorttag:t
  207. sgml-minimize-attributes:nil
  208. sgml-always-quote-attributes:t
  209. sgml-indent-step:1
  210. sgml-indent-data:t
  211. sgml-parent-document:nil
  212. sgml-default-dtd-file:"../reference.ced"
  213. sgml-exposed-tags:nil
  214. sgml-local-catalogs:"/usr/lib/sgml/catalog"
  215. sgml-local-ecat-files:nil
  216. End:
  217. -->