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
f08c9ff8
Commit
f08c9ff8
authored
Oct 22, 2001
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the CREATE TABLE ref page more readable and update some information.
parent
e97fe98c
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
842 additions
and
2120 deletions
+842
-2120
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/alter_table.sgml
+7
-9
doc/src/sgml/ref/create_table.sgml
doc/src/sgml/ref/create_table.sgml
+689
-1996
doc/src/sgml/ref/create_table_as.sgml
doc/src/sgml/ref/create_table_as.sgml
+130
-109
doc/src/sgml/ref/select_into.sgml
doc/src/sgml/ref/select_into.sgml
+5
-5
doc/src/sgml/stylesheet.dsl
doc/src/sgml/stylesheet.dsl
+11
-1
No files found.
doc/src/sgml/ref/alter_table.sgml
View file @
f08c9ff8
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.
29 2001/10/12 00:07:14 tgl
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.
30 2001/10/22 18:14:47 petere
Exp $
Postgres documentation
Postgres documentation
-->
-->
...
@@ -161,15 +161,14 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
...
@@ -161,15 +161,14 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
<para>
<para>
<command>ALTER TABLE</command> changes the definition of an existing table.
<command>ALTER TABLE</command> changes the definition of an existing table.
The <literal>ADD COLUMN</literal> form adds a new column to the table
The <literal>ADD COLUMN</literal> form adds a new column to the table
using the same syntax as <xref linkend="SQL-CREATETABLE"
using the same syntax as <xref linkend="SQL-CREATETABLE">.
endterm="SQL-CREATETABLE-title">.
The <literal>ALTER COLUMN SET/DROP DEFAULT</literal> forms
The <literal>ALTER COLUMN SET/DROP DEFAULT</literal> forms
allow you to set or remove the default for the column. Note that defaults
allow you to set or remove the default for the column. Note that defaults
only apply to subsequent <command>INSERT</command> commands; they do not
only apply to subsequent <command>INSERT</command> commands; they do not
cause rows already in the table to change.
cause rows already in the table to change.
The <literal>ALTER COLUMN SET STATISTICS</literal> form allows you to
The <literal>ALTER COLUMN SET STATISTICS</literal> form allows you to
set the statistics-gathering target for subsequent
set the statistics-gathering target for subsequent
<xref linkend="sql-analyze"
endterm="sql-analyze-title"
> operations.
<xref linkend="sql-analyze"> operations.
The <literal>RENAME</literal> clause causes the name of a table or column
The <literal>RENAME</literal> clause causes the name of a table or column
to change without changing any of the data contained in
to change without changing any of the data contained in
the affected table. Thus, the table or column will
the affected table. Thus, the table or column will
...
@@ -177,7 +176,7 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
...
@@ -177,7 +176,7 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
executed.
executed.
The ADD <replaceable class="PARAMETER">table constraint definition</replaceable> clause
The ADD <replaceable class="PARAMETER">table constraint definition</replaceable> clause
adds a new constraint to the table using the same syntax as <xref
adds a new constraint to the table using the same syntax as <xref
linkend="SQL-CREATETABLE"
endterm="SQL-CREATETABLE-title"
>.
linkend="SQL-CREATETABLE">.
The DROP CONSTRAINT <replaceable class="PARAMETER">constraint</replaceable> clause
The DROP CONSTRAINT <replaceable class="PARAMETER">constraint</replaceable> clause
drops all CHECK constraints on the table (and its children) that match <replaceable class="PARAMETER">constraint</replaceable>.
drops all CHECK constraints on the table (and its children) that match <replaceable class="PARAMETER">constraint</replaceable>.
The OWNER clause changes the owner of the table to the user <replaceable class="PARAMETER">
The OWNER clause changes the owner of the table to the user <replaceable class="PARAMETER">
...
@@ -205,18 +204,17 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
...
@@ -205,18 +204,17 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
You can use the <literal>SET DEFAULT</literal> form
You can use the <literal>SET DEFAULT</literal> form
of <command>ALTER TABLE</command> to set the default later.
of <command>ALTER TABLE</command> to set the default later.
(You may also want to update the already existing rows to the
(You may also want to update the already existing rows to the
new default value, using <xref linkend="sql-update"
new default value, using <xref linkend="sql-update">.)
endterm="sql-update-title">.)
</para>
</para>
<para>
<para>
Currently only CHECK constraints can be dropped from a table. The RESTRICT
Currently only CHECK constraints can be dropped from a table. The RESTRICT
keyword is required, although dependencies are not checked. The CASCADE
keyword is required, although dependencies are not checked. The CASCADE
option is unsupported. To remove a PRIMARY or UNIQUE constraint, drop the
option is unsupported. To remove a PRIMARY or UNIQUE constraint, drop the
relevant index using the <xref linkend="SQL-DROPINDEX"
endterm="SQL-DROPINDEX-TITLE"
> command.
relevant index using the <xref linkend="SQL-DROPINDEX"> command.
To remove FOREIGN KEY constraints you need to recreate
To remove FOREIGN KEY constraints you need to recreate
and reload the table, using other parameters to the
and reload the table, using other parameters to the
<xref linkend="SQL-CREATETABLE"
endterm="SQL-CREATETABLE-title"
>
<xref linkend="SQL-CREATETABLE">
command.
command.
</para>
</para>
<para>
<para>
...
...
doc/src/sgml/ref/create_table.sgml
View file @
f08c9ff8
This diff is collapsed.
Click to expand it.
doc/src/sgml/ref/create_table_as.sgml
View file @
f08c9ff8
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.
7 2001/09/03 12:57:49
petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.
8 2001/10/22 18:14:47
petere Exp $
Postgres documentation
Postgres documentation
-->
-->
<refentry id="SQL-CREATETABLEAS">
<refentry id="SQL-CREATETABLEAS">
<refmeta>
<refmeta>
<refentrytitle id="SQL-CREATETABLEAS-TITLE">
<refentrytitle>CREATE TABLE AS</refentrytitle>
CREATE TABLE AS
</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
</refmeta>
<refnamediv>
<refnamediv>
<refname>
<refname>CREATE TABLE AS</refname>
CREATE TABLE AS
<refpurpose>create a new table from the results of a query</refpurpose>
</refname>
<refpurpose>
create a new table from the results of a query
</refpurpose>
</refnamediv>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<synopsis>
<date>2001-03-03</date>
CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ]
</refsynopsisdivinfo>
AS <replaceable>query</replaceable>
<synopsis>
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable>table</replaceable> [ (<replaceable>column</replaceable> [, ...] ) ]
AS <replaceable>select_clause</replaceable>
</synopsis>
</synopsis>
<refsect2>
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Inputs
</title>
<para>
<variablelist>
<varlistentry>
<term>TEMPORARY or TEMP</term>
<listitem>
<para>
If specified, the table is created only within this session, and is
automatically dropped on session exit.
Existing permanent tables with the same name are not visible
(in this session) while the temporary table exists.
Any indexes created on a temporary table are automatically
temporary as well.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>table</replaceable></term>
<listitem>
<para>
The name of the new table to be created.
This table must not already exist. However, a temporary table
can be created that has the same name as an existing permanent
table.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>column</replaceable></term>
<listitem>
<para>
The name of a column. Multiple column names can be specified using
a comma-delimited list of column names. If column names are not
provided, they are taken from the output column names of the
SELECT query.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>select_clause</replaceable></term>
<listitem>
<para>
A valid query statement. Refer to
<xref linkend="sql-select" endterm="sql-select-title">
for a description of the allowed syntax.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2>
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Outputs
</title>
<para>
Refer to
<xref linkend="sql-createtable" endterm="sql-createtable-title">
and
<xref linkend="sql-select" endterm="sql-select-title">
for a summary of possible output messages.
</para>
</refsect2>
</refsynopsisdiv>
</refsynopsisdiv>
<refsect1>
<refsect1>
<refsect1info>
<refsect1info>
<date>2001-03-20</date>
<date>2001-03-20</date>
...
@@ -117,28 +31,135 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable>table</replaceable> [ (<replaceab
...
@@ -117,28 +31,135 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable>table</replaceable> [ (<replaceab
<para>
<para>
<command>CREATE TABLE AS</command> creates a table and fills it
<command>CREATE TABLE AS</command> creates a table and fills it
with data computed by a <command>SELECT</command> command. The
with data computed by a <command>SELECT</command> command. The
table columns have the names and datatypes associated with the
table columns have the names and data
types associated with the
output columns of the <command>SELECT</command> (except that you
output columns of the <command>SELECT</command> (except that you
can override the <command>SELECT</command> column names by giving
can override the column names by giving an explicit list of new
an explicit list of column names).
column names).
</para>
<para>
<command>CREATE TABLE AS</command> bears some resemblance to
creating a view, but it is really quite different: it creates a new
table and evaluates the query just once to fill the new table
initially. The new table will not track subsequent changes to the
source tables of the query. In contrast, a view re-evaluates the
underlying <command>SELECT</command> statements whenever it is
queried.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><literal>[LOCAL] TEMPORARY</> or <literal>[LOCAL] TEMP</></term>
<listitem>
<para>
If specified, the table is created as a temporary table.
Temporary tables are automatically dropped at the end of a
session. Existing persistent tables with the same name are not
visible to the current session while the temporary table exists.
Any indexes created on a temporary table are automatically
temporary as well.
</para>
<para>
The <literal>LOCAL</literal> word is optional.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>table_name</replaceable></term>
<listitem>
<para>
The name of the new table to be created. This table must not
already exist. However, a temporary table can be created that
has the same name as an existing permanent table.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>column_name</replaceable></term>
<listitem>
<para>
The name of a column in the new table. Multiple column names can
be specified using a comma-delimited list of column names. If
column names are not provided, they are taken from the output
column names of the query.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>query</replaceable></term>
<listitem>
<para>
A query statement (that is, a <command>SELECT</command>
command). Refer to
<xref linkend="sql-select">
for a description of the allowed syntax.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Diagnostics</title>
<para>
Refer to <xref linkend="sql-createtable"> and
<xref linkend="sql-select">
for a summary of possible output messages.
</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
This command is functionally equivalent to <xref
linkend="sql-selectinto">, but it is preferred since it is less
likely to be confused with other uses of the <command>SELECT
... INTO</command> syntax.
</para>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<para>
<command>CREATE TABLE AS</command> bears some resemblance to creating
This command is modeled after an <productname>Oracle</productname>
a view, but it is really quite different: it creates a new table and
feature. There is no command with equivalent functionality in
evaluates the <command>SELECT</command> just once to fill the new table
SQL92 or SQL99. However, a combination of <literal>CREATE
initially. The new table will not track subsequent changes to
TABLE</literal> and <literal>INSERT ... SELECT</literal> can
the source tables of the <command>SELECT</command>. In contrast,
accomplish the same thing with little more effort.
a view re-evaluates the given <command>SELECT</command> whenever queried.
</para>
</para>
</refsect1>
<refsect1>
<title>History</title>
<para>
<para>
This command is functionally equivalent to
The <command>CREATE TABLE AS</command> command has been available
<xref linkend="sql-selectinto" endterm="sql-selectinto-title">,
since <productname>PostgreSQL</productname> 6.3.
but it is preferred since it is less likely to be confused with
other uses of the <command>SELECT ... INTO</command> syntax.
</para>
</para>
</refsect1>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-createtable"></member>
<member><xref linkend="sql-createview"></member>
<member><xref linkend="sql-select"></member>
<member><xref linkend="sql-selectinto"></member>
</simplelist>
</refsect1>
</refentry>
</refentry>
<!-- Keep this comment at the end of the file
<!-- Keep this comment at the end of the file
...
...
doc/src/sgml/ref/select_into.sgml
View file @
f08c9ff8
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select_into.sgml,v 1.1
2 2001/09/23 13:34:44 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select_into.sgml,v 1.1
3 2001/10/22 18:14:47 petere
Exp $
Postgres documentation
Postgres documentation
-->
-->
...
@@ -89,7 +89,7 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
...
@@ -89,7 +89,7 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
<para>
<para>
All other inputs are described in detail for
All other inputs are described in detail for
<xref linkend="sql-select"
endterm="sql-select-title"
>.
<xref linkend="sql-select">.
</para>
</para>
</refsect2>
</refsect2>
...
@@ -103,9 +103,9 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
...
@@ -103,9 +103,9 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
<para>
<para>
Refer to
Refer to
<xref linkend="sql-createtable"
endterm="sql-createtable-title"
>
<xref linkend="sql-createtable">
and
and
<xref linkend="sql-select"
endterm="sql-select-title"
>
<xref linkend="sql-select">
for a summary of possible output messages.
for a summary of possible output messages.
</para>
</para>
</refsect2>
</refsect2>
...
@@ -128,7 +128,7 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
...
@@ -128,7 +128,7 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
<note>
<note>
<para>
<para>
<xref linkend="sql-createtableas"
endterm="sql-createtableas-title"
>
<xref linkend="sql-createtableas">
is functionally equivalent to <command>SELECT INTO</command>.
is functionally equivalent to <command>SELECT INTO</command>.
<command>CREATE TABLE AS</command> is the recommended syntax, since
<command>CREATE TABLE AS</command> is the recommended syntax, since
<command>SELECT INTO</command> is not standard. In fact, this form of
<command>SELECT INTO</command> is not standard. In fact, this form of
...
...
doc/src/sgml/stylesheet.dsl
View file @
f08c9ff8
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/stylesheet.dsl,v 1.1
4 2001/10/09 18:46:00
petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/stylesheet.dsl,v 1.1
5 2001/10/22 18:14:47
petere Exp $ -->
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!-- must turn on one of these with -i on the jade command line -->
<!-- must turn on one of these with -i on the jade command line -->
...
@@ -123,6 +123,16 @@
...
@@ -123,6 +123,16 @@
;;; XXX The above is very ugly. It might be better to run 'tidy' on
;;; XXX The above is very ugly. It might be better to run 'tidy' on
;;; the resulting *.html files.
;;; the resulting *.html files.
;; Format multiple terms in varlistentry vertically, instead
;; of comma-separated.
(element (varlistentry term)
(make sequence
(process-children-trim)
(if (not (last-sibling?))
(make empty-element gi: "BR")
(empty-sosofo))))
]]> <!-- %output-html -->
]]> <!-- %output-html -->
<![ %output-print; [
<![ %output-print; [
...
...
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