Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

RedHat 5.2

(Apollo)

alter_table(l)


ALTER TABLE

ALTER TABLE

NAME
SYNOPSIS
DESCRIPTION
EXAMPLE
SEE ALSO

NAME

alter table - add attributes to a class, or rename an attribute or class

SYNOPSIS

alter table classname [ * ]

add [ column ] attname type

alter table classname [ * ]

add ( attname type )

alter table classname1

rename to classname2

alter table classname1 [*]

rename [column] attname1 to attname2

DESCRIPTION

The alter table command causes a new attribute to be added to an existing class, 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.

The new attributes and their types are specified in the same style and with the the same restrictions as in create table(l).

In order to add an attribute to each class in an entire inheritance hierarchy, use the classname of the superclass and append a “*”. (By default, the attribute will not be added to any of the subclasses.) This should always be done when adding an attribute to a superclass. If it is not, queries on the inheritance hierarchy such as

select * from super* s

will not work because the subclasses will be missing an attribute found in the superclass.

For efficiency reasons, default values for added attributes are not placed in existing instances of a class. That is, existing instances will have NULL values in the new attributes. If non-NULL values are desired, a subsequent update(l) query should be run.

In order to rename an attribute in each class in an entire inheritance hierarchy, use the classname of the superclass and append a “*”. (By default, the attribute will not be renamed in any of the subclasses.) This should always be done when changing an attribute name in a superclass. If it is not, queries on the inheritance hierarchy such as
select * from super* s
will not work because the subclasses will be (in effect) missing an attribute found in the superclass.

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.

You must own the class in order to change its schema.

EXAMPLE

--
-- add the date of hire to the emp class
--
alter table emp add column hiredate abstime
--
-- 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

SEE ALSO

create table (l), update (l).



alter_table(l)