aboutsummaryrefslogtreecommitdiff
path: root/src/man/alter_table.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/man/alter_table.l')
-rw-r--r--src/man/alter_table.l59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/man/alter_table.l b/src/man/alter_table.l
index 67f50de8942..81929ff5b30 100644
--- a/src/man/alter_table.l
+++ b/src/man/alter_table.l
@@ -1,25 +1,33 @@
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/alter_table.l,v 1.4 1998/01/11 22:17:04 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/alter_table.l,v 1.5 1998/03/31 04:44:19 momjian Exp $
.TH "ALTER TABLE" SQL 09/25/97 PostgreSQL
.SH NAME
-alter table - add attributes to a class
+alter table - add attributes to a class, or rename an attribute or class
.SH SYNOPSIS
.nf
\fBalter table\fR classname [ * ]
\fBadd\fR [ \fBcolumn\fR ] attname type
-.fi
-.nf
\fBalter table\fR classname [ * ]
\fBadd\fR \fB(\fR attname type \fB)\fR
+\fBalter table\fR classname1
+ \fBrename to\fR classname2
+
+\fBalter table\fR classname1 [\fB*\fR]
+ \fBrename [column]\fR attname1 \fBto\fR attname2
.fi
+
.SH DESCRIPTION
The
.BR "alter table"
-command
-causes a new attribute to be added to an existing class,
-.IR classname .
+command causes a new attribute to be added to an existing class,
+.IR classname ,
+or the name of a class or attribute to change
+without changing any of the data contained in the affected class.
+Thus, the class or attribute will remain of the same type and size
+after this command is executed.
+.PP
The new attributes and their types are specified
in the same style and with the the same restrictions as in
.IR "create table" (l).
@@ -33,7 +41,9 @@ attribute will not be added to any of the subclasses.) This should
be done when adding an attribute to a superclass. If it is not,
queries on the inheritance hierarchy such as
.nf
-select * from super* s
+
+ select * from super* s
+
.fi
will not work because the subclasses will be missing an attribute
found in the superclass.
@@ -45,6 +55,24 @@ desired, a subsequent
.IR update (l)
query should be run.
.PP
+In order to rename an attribute in each class in an entire inheritance
+hierarchy, use the
+.IR classname
+of the superclass and append a \*(lq*\*(rq. (By default, the attribute
+will not be renamed in any of the subclasses.) This should
+.BR always
+be done when changing an attribute name in a superclass. If it is
+not, queries on the inheritance hierarchy such as
+.nf
+select * from super* s
+.fi
+will not work because the subclasses will be (in effect) missing an
+attribute found in the superclass.
+.PP
+You must own the class being modified in order to rename it or part of
+its schema. Renaming any part of the schema of a system catalog is
+not permitted.
+.PP
You must own the class in order to change its schema.
.SH EXAMPLE
.nf
@@ -52,14 +80,25 @@ You must own the class in order to change its schema.
-- add the date of hire to the emp class
--
alter table emp add column hiredate abstime
-.fi
-.nf
--
-- add a health-care number to all persons
-- (including employees, students, ...)
--
alter table person * add column health_care_id int4
+--
+-- change the emp class to personnel
+--
+alter table emp rename to personnel
+--
+-- change the sports attribute to hobbies
+--
+alter table emp rename column sports to hobbies
+--
+-- make a change to an inherited attribute
+--
+alter table person * rename column last_name to family_name
.fi
.SH "SEE ALSO"
create table (l),
update (l).
+