mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Indent markup using emacs.
This commit is contained in:
parent
1def28ff20
commit
f8aa366ddd
@ -1,174 +1,170 @@
|
|||||||
<Chapter Id="manage">
|
<Chapter Id="manage">
|
||||||
<Title>Managing a Database</Title>
|
<Title>Managing a Database</Title>
|
||||||
|
|
||||||
<Para>
|
<Note>
|
||||||
<Note>
|
<Para>
|
||||||
<Para>
|
This section is currently a thinly disguised copy of the
|
||||||
This section is currently a thinly disguised copy of the Tutorial. Needs to be augmented.
|
Tutorial. Needs to be augmented.
|
||||||
- thomas 1998-01-12
|
- thomas 1998-01-12
|
||||||
</Para>
|
</Para>
|
||||||
</Note>
|
</Note>
|
||||||
</Para>
|
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
Although the <FirstTerm>site administrator</FirstTerm> is responsible for overall management
|
Although the <FirstTerm>site administrator</FirstTerm> is responsible for overall management
|
||||||
of the <ProductName>Postgres</ProductName> installation, some databases within the
|
of the <ProductName>Postgres</ProductName> installation, some databases within the
|
||||||
installation may be managed by another person,
|
installation may be managed by another person,
|
||||||
designated the <FirstTerm>database administrator</FirstTerm>.
|
designated the <FirstTerm>database administrator</FirstTerm>.
|
||||||
This assignment of responsibilities occurs when a database is created.
|
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 may be assigned explicit privileges to create databases and/or to create new users.
|
||||||
A user assigned both privileges can perform most administrative task
|
A user assigned both privileges can perform most administrative task
|
||||||
within <ProductName>Postgres</ProductName>, but will
|
within <ProductName>Postgres</ProductName>, but will
|
||||||
not by default have the same operating system privileges as the site administrator.
|
not by default have the same operating system privileges as the site administrator.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
The Database Administrator's Guide covers these topics in more detail.
|
The Database Administrator's Guide covers these topics in more detail.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Sect1>
|
<Sect1>
|
||||||
<Title>Database Creation</Title>
|
<Title>Database Creation</Title>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
Databases are created by the <Command>create database</Command> issued from
|
Databases are created by the <Command>create database</Command> issued from
|
||||||
within <ProductName>Postgres</ProductName>. <Application>createdb</Application> is a command-line
|
within <ProductName>Postgres</ProductName>. <Application>createdb</Application> is a command-line
|
||||||
utility provided to give the same functionality from outside <ProductName>Postgres</ProductName>.
|
utility provided to give the same functionality from outside <ProductName>Postgres</ProductName>.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
The <ProductName>Postgres</ProductName> backend must be running for either method
|
The <ProductName>Postgres</ProductName> backend must be running for either method
|
||||||
to succeed, and the user issuing the command must be the <ProductName>Postgres</ProductName>
|
to succeed, and the user issuing the command must be the <ProductName>Postgres</ProductName>
|
||||||
<FirstTerm>superuser</FirstTerm> or have been assigned database creation privileges by the
|
<FirstTerm>superuser</FirstTerm> or have been assigned database creation privileges by the
|
||||||
superuser.
|
superuser.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
To create a new database named <Quote>mydb</Quote> from the command line, type
|
To create a new database named <Quote>mydb</Quote> from the command line, type
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
% createdb mydb
|
% createdb mydb
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
|
|
||||||
and to do the same from within <Application>psql</Application> type
|
and to do the same from within <Application>psql</Application> type
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
* CREATE DATABASE mydb;
|
* CREATE DATABASE mydb;
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
If you do not have the privileges required to create a database, you will see
|
If you do not have the privileges required to create a database, you will see
|
||||||
the following:
|
the following:
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
% createdb mydb
|
% createdb mydb
|
||||||
WARN:user "your username" is not allowed to create/destroy databases
|
WARN:user "your username" is not allowed to create/destroy databases
|
||||||
createdb: database creation failed on mydb.
|
createdb: database creation failed on mydb.
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
<ProductName>Postgres</ProductName> allows you to create any number of databases
|
<ProductName>Postgres</ProductName> allows you to create any number of databases
|
||||||
at a given site and you automatically become the
|
at a given site and you automatically become the
|
||||||
database administrator of the database you just created.
|
database administrator of the database you just created.
|
||||||
Database names must have an alphabetic first
|
Database names must have an alphabetic first
|
||||||
character and are limited to 32 characters in length.
|
character and are limited to 32 characters in length.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
</Sect1>
|
</Sect1>
|
||||||
|
|
||||||
<Sect1>
|
<Sect1>
|
||||||
<Title>Alternate Database Locations</Title>
|
<Title>Alternate Database Locations</Title>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
It is possible to create a database in a location other than the default
|
It is possible to create a database in a location other than the default
|
||||||
location for the installation. Remember that all database access actually
|
location for the installation. Remember that all database access actually
|
||||||
occurs through the database backend, so that any location specified must
|
occurs through the database backend, so that any location specified must
|
||||||
be accessible by the backend.
|
be accessible by the backend.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
Alternate database locations are created and referenced by an environment variable
|
Alternate database locations are created and referenced by an environment variable
|
||||||
which gives the absolute path to the intended storage location.
|
which gives the absolute path to the intended storage location.
|
||||||
This environment variable must have been defined before the backend was started
|
This environment variable must have been defined before the backend was started
|
||||||
and the location it points to must be writable by the postgres administrator account.
|
and the location it points to must be writable by the postgres administrator account.
|
||||||
Consult with the site administrator
|
Consult with the site administrator
|
||||||
regarding preconfigured alternate database locations.
|
regarding preconfigured alternate database locations.
|
||||||
Any valid environment variable name may be used to reference an alternate location,
|
Any valid environment variable name may be used to reference an alternate location,
|
||||||
although using variable names with a prefix of <quote>PGDATA</quote> is recommended
|
although using variable names with a prefix of <quote>PGDATA</quote> is recommended
|
||||||
to avoid confusion
|
to avoid confusion
|
||||||
and conflict with other variables.
|
and conflict with other variables.
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
<Para>
|
<Para>
|
||||||
In previous versions of <ProductName>Postgres</ProductName>,
|
In previous versions of <ProductName>Postgres</ProductName>,
|
||||||
it was also permissable to use an absolute path name to specify
|
it was also permissable to use an absolute path name to specify
|
||||||
an alternate storage location.
|
an alternate storage location.
|
||||||
Although the environment variable style of specification
|
Although the environment variable style of specification
|
||||||
is to be preferred since it allows the site administrator more flexibility in
|
is to be preferred since it allows the site administrator more flexibility in
|
||||||
managing disk storage, it is also possible to use an absolute path
|
managing disk storage, it is also possible to use an absolute path
|
||||||
to specify an alternate location.
|
to specify an alternate location.
|
||||||
The administrator's guide discusses how to enable this feature.
|
The administrator's guide discusses how to enable this feature.
|
||||||
</Para>
|
</Para>
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
For security and integrity reasons,
|
For security and integrity reasons,
|
||||||
any path or environment variable specified has some
|
any path or environment variable specified has some
|
||||||
additional path fields appended.
|
additional path fields appended.
|
||||||
</Para>
|
Alternate database locations must be prepared by running
|
||||||
|
<Application>initlocation</Application>.
|
||||||
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
Alternate database locations must be prepared by running
|
To create a data storage area using the environment variable
|
||||||
<Application>initlocation</Application>.
|
<envar>PGDATA2</envar> (for this example set to <filename>/alt/postgres</filename>),
|
||||||
</Para>
|
ensure that <FileName>/alt/postgres</FileName> already exists and is writable by
|
||||||
|
the Postgres administrator account.
|
||||||
<Para>
|
Then, from the command line, type
|
||||||
To create a data storage area using the environment variable
|
<ProgramListing>
|
||||||
<envar>PGDATA2</envar> (for this example set to <filename>/alt/postgres</filename>),
|
|
||||||
ensure that <FileName>/alt/postgres</FileName> already exists and is writable by
|
|
||||||
the Postgres administrator account.
|
|
||||||
Then, from the command line, type
|
|
||||||
<ProgramListing>
|
|
||||||
% initlocation $PGDATA2
|
% initlocation $PGDATA2
|
||||||
Creating Postgres database system directory /alt/postgres/data
|
Creating Postgres database system directory /alt/postgres/data
|
||||||
Creating Postgres database system directory /alt/postgres/data/base
|
Creating Postgres database system directory /alt/postgres/data/base
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
To create a database in the alternate storage area <envar>PGDATA2</envar>
|
To create a database in the alternate storage area <envar>PGDATA2</envar>
|
||||||
from the command line, use the following command:
|
from the command line, use the following command:
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
% createdb -D PGDATA2 mydb
|
% createdb -D PGDATA2 mydb
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
|
|
||||||
To do the same from within <Application>psql</Application> type
|
and to do the same from within <Application>psql</Application> type
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
* CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
|
* CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
If you do not have the privileges required to create a database, you will see
|
If you do not have the privileges required to create a database, you will see
|
||||||
the following:
|
the following:
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
% createdb mydb
|
% createdb mydb
|
||||||
WARN:user "your username" is not allowed to create/destroy databases
|
WARN:user "your username" is not allowed to create/destroy databases
|
||||||
createdb: database creation failed on mydb.
|
createdb: database creation failed on mydb.
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
<Para>
|
<Para>
|
||||||
If the specified location does not exist or the database backend does not have
|
If the specified location does not exist or the database backend does not have
|
||||||
permission to access it or to write to directories under it, you will see
|
permission to access it or to write to directories under it, you will see
|
||||||
the following:
|
the following:
|
||||||
<ProgramListing>
|
<ProgramListing>
|
||||||
% createdb -D /alt/postgres/data mydb
|
% createdb -D /alt/postgres/data mydb
|
||||||
ERROR: Unable to create database directory /alt/postgres/data/base/mydb
|
ERROR: Unable to create database directory /alt/postgres/data/base/mydb
|
||||||
createdb: database creation failed on mydb.
|
createdb: database creation failed on mydb.
|
||||||
</ProgramListing>
|
</ProgramListing>
|
||||||
</Para>
|
</Para>
|
||||||
|
|
||||||
</Sect1>
|
</Sect1>
|
||||||
|
|
||||||
<Sect1>
|
<Sect1>
|
||||||
<Title>Accessing a Database</Title>
|
<Title>Accessing a Database</Title>
|
||||||
@ -296,3 +292,20 @@ TBD
|
|||||||
</Sect1>
|
</Sect1>
|
||||||
|
|
||||||
</Chapter>
|
</Chapter>
|
||||||
|
|
||||||
|
<!-- Keep this comment at the end of the file
|
||||||
|
Local variables:
|
||||||
|
mode: sgml
|
||||||
|
sgml-omittag:nil
|
||||||
|
sgml-shorttag:t
|
||||||
|
sgml-minimize-attributes:nil
|
||||||
|
sgml-always-quote-attributes:t
|
||||||
|
sgml-indent-step:1
|
||||||
|
sgml-indent-data:t
|
||||||
|
sgml-parent-document:nil
|
||||||
|
sgml-default-dtd-file:"./reference.ced"
|
||||||
|
sgml-exposed-tags:nil
|
||||||
|
sgml-local-catalogs:"/usr/lib/sgml/CATALOG"
|
||||||
|
sgml-local-ecat-files:nil
|
||||||
|
End:
|
||||||
|
-->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user