Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c2f14a7c
Commit
c2f14a7c
authored
Aug 07, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve tablespace discussion, and bring it up to date with code.
parent
ff2c8950
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
20 deletions
+53
-20
doc/src/sgml/manage-ag.sgml
doc/src/sgml/manage-ag.sgml
+53
-20
No files found.
doc/src/sgml/manage-ag.sgml
View file @
c2f14a7c
<!--
$PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.3
1 2004/06/21 04:06:0
3 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.3
2 2004/08/07 19:02:4
3 tgl Exp $
-->
<chapter id="managing-databases">
...
...
@@ -32,8 +32,8 @@ $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.31 2004/06/21 04:06:03 tgl Ex
are accessible from each database within the cluster.) More
accurately, a database is a collection of schemas and the schemas
contain the tables, functions, etc. So the full hierarchy is:
server, database, schema, table (or some
thing else instead of a
table
).
server, database, schema, table (or some
other kind of object,
such as a function
).
</para>
<para>
...
...
@@ -58,8 +58,8 @@ $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.31 2004/06/21 04:06:03 tgl Ex
<note>
<para>
<acronym>SQL</> calls databases <quote>catalogs</>, but there is no
difference in practice.
The <acronym>SQL</> standard calls databases <quote>catalogs</>, but there
is no
difference in practice.
</para>
</note>
</sect1>
...
...
@@ -68,14 +68,16 @@ $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.31 2004/06/21 04:06:03 tgl Ex
<title>Creating a Database</title>
<para>
In order to create a database
s
, the <productname>PostgreSQL</>
In order to create a database, the <productname>PostgreSQL</>
server must be up and running (see <xref
linkend="postmaster-start">).
</para>
<para>
Databases are created with the SQL command <command>CREATE
DATABASE</command>:<indexterm><primary>CREATE DATABASE</></>
Databases are created with the SQL command
<xref linkend="sql-createdatabase"
endterm="sql-createdatabase-title">:<indexterm><primary>CREATE
DATABASE</></>
<synopsis>
CREATE DATABASE <replaceable>name</>;
</synopsis>
...
...
@@ -105,7 +107,7 @@ CREATE DATABASE <replaceable>name</>;
</para>
<para>
The name <literal>template1</literal> is no accident:
W
hen a new
The name <literal>template1</literal> is no accident:
w
hen a new
database is created, the template database is essentially cloned.
This means that any changes you make in <literal>template1</> are
propagated to all subsequently created databases. This implies that
...
...
@@ -280,8 +282,8 @@ createdb -T template0 <replaceable>dbname</>
<acronym>GEQO</acronym> optimizer for a given database, you'd
ordinarily have to either disable it for all databases or make sure
that every connecting client is careful to issue <literal>SET geqo
TO off;</literal>. To make this setting the default
you can
execute the command
TO off;</literal>. To make this setting the default
within a particular
database, you can
execute the command
<programlisting>
ALTER DATABASE mydb SET geqo TO off;
</programlisting>
...
...
@@ -299,12 +301,13 @@ ALTER DATABASE mydb SET geqo TO off;
<title>Destroying a Database</title>
<para>
Databases are destroyed with the command <command>DROP
DATABASE</command>:<indexterm><primary>DROP DATABASE</></>
Databases are destroyed with the command
<xref linkend="sql-dropdatabase"
endterm="sql-dropdatabase-title">:<indexterm><primary>DROP DATABASE</></>
<synopsis>
DROP DATABASE <replaceable>name</>;
</synopsis>
Only the owner of the database (i.e., the user that created it) or
Only the owner of the database (i.e., the user that created it)
,
or
a superuser, can drop a database. Dropping a database removes all objects
that were
contained within the database. The destruction of a database cannot
...
...
@@ -335,7 +338,7 @@ dropdb <replaceable class="parameter">dbname</replaceable>
<title>Tablespaces</title>
<para>
Tablespaces in <productname>PostgreSQL</> allow database
superuse
rs to
Tablespaces in <productname>PostgreSQL</> allow database
administrato
rs to
define locations in the file system where the files representing
database objects can be stored. Once created, a tablespace can be referred
to by name when creating database objects.
...
...
@@ -360,7 +363,37 @@ dropdb <replaceable class="parameter">dbname</replaceable>
</para>
<para>
Databases, schemas, tables, indexes and sequences can all be placed in
To define a tablespace, use the <xref linkend="sql-createtablespace"
endterm="sql-createtablespace-title"> command, for
example:<indexterm><primary>CREATE TABLESPACE</></>
<programlisting>
CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';
</programlisting>
The location must be an existing, empty directory that is owned by
the <productname>PostgreSQL</> system user. All objects subsequently
created within the tablespace will be stored in files underneath this
directory.
</para>
<note>
<para>
There is usually not much point in making more than one
tablespace per logical filesystem, since you can't control the location
of individual files within a logical filesystem. However,
<productname>PostgreSQL</> does not enforce any such limitation, and
indeed it's not directly aware of the filesystem boundaries on your
system. It just stores files in the directories you tell it to use.
</para>
</note>
<para>
Creation of the tablespace itself must be done as a database superuser,
but after that you can allow ordinary database users to make use of it.
To do that, grant them the <literal>CREATE</> privilege on it.
</para>
<para>
Databases, schemas, tables, and indexes can all be assigned to
particular tablespaces. To do so, a user with the <literal>CREATE</>
privilege on a given tablespace must pass the tablespace name as a
parameter to the relevant command. For example, the following creates
...
...
@@ -385,7 +418,7 @@ CREATE TABLE foo(i int) TABLESPACE space1;
A schema does not in itself occupy any storage (other than a system
catalog entry), so assigning a tablespace to a schema does not in itself
do anything. What this actually does is to set a default tablespace
for tables
, indexes, and sequences
later created within the schema. If
for tables later created within the schema. If
no tablespace is mentioned when creating a schema, it inherits its
default tablespace from the current database.
</para>
...
...
@@ -396,10 +429,10 @@ CREATE TABLE foo(i int) TABLESPACE space1;
</para>
<para>
Another way to state the above rules is that when a schema, table, index
or sequence
is created without specifying a tablespace, the object
Another way to state the above rules is that when a schema, table,
or
index
is created without specifying a tablespace, the object
inherits its logical parent's tablespace. A schema will be created in the
current database's tablespace; a table
or sequence
will be created in the
current database's tablespace; a table will be created in the
tablespace of the schema it is being created in; an index will be created
in the tablespace of the table underlying the index.
</para>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment