Provided by: manpages-zh_1.5.2-1_all bug

NAME

       ALTER TABLE -

SYNOPSIS

       ALTER TABLE [ ONLY ] name [ * ]
           ADD [ COLUMN ] column type [ column_constraint [ ... ] ]
       ALTER TABLE [ ONLY ] name [ * ]
           DROP [ COLUMN ] column [ RESTRICT | CASCADE ]
       ALTER TABLE [ ONLY ] name [ * ]
           ALTER [ COLUMN ] column { SET DEFAULT expression | DROP DEFAULT }
       ALTER TABLE [ ONLY ] name [ * ]
           ALTER [ COLUMN ] column { SET | DROP } NOT NULL
       ALTER TABLE [ ONLY ] name [ * ]
           ALTER [ COLUMN ] column SET STATISTICS integer
       ALTER TABLE [ ONLY ] name [ * ]
           ALTER [ COLUMN ] column SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
       ALTER TABLE [ ONLY ] name [ * ]
           SET WITHOUT OIDS
       ALTER TABLE [ ONLY ] name [ * ]
           RENAME [ COLUMN ] column TO new_column
       ALTER TABLE name
           RENAME TO new_name
       ALTER TABLE [ ONLY ] name [ * ]
           ADD table_constraint
       ALTER TABLE [ ONLY ] name [ * ]
           DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ]
       ALTER TABLE name
           OWNER TO new_owner
       ALTER TABLE name
           CLUSTER ON index_name

DESCRIPTION

       ALTER TABLE

       ADD COLUMN
                CREATE TABLE [create_table(7)]

       DROP COLUMN
                  CASCADE

       SET/DROP DEFAULT
                INSERT    ON INSERT  INSERT

       SET/DROP NOT NULL
                NULL  NULL   SET NOT NULL

       SET STATISTICS
              This form
                ANALYZE [analyze(7)]   0  1000  -1

       SET STORAGE
                 PLAIN  integer MAIN  EXTERNAL   EXTENDED  EXTENDED   EXTERNAL
              text

       SET WITHOUT OIDS
                oid oid  OID  OID  DROP COLUMN

       RENAME RENAME

       ADD table_constraint
                CREATE TABLE [create_table(7)]

       DROP CONSTRAINT

       OWNER

       CLUSTER
                CLUSTER [cluster(7)]

         ALTER TABLE  ALTER TABLE OWNER

PARAMETERS

       name
                 ONLY  ONLY  *  7.1ONLY  SQL_INHERITANCE

       column

       type

       new_column

       new_name

       table_constraint

       constraint_name

       new_owner

       index_name

       CASCADE

       RESTRICT

NOTES

        COLUMN

         ADD  COLUMN/  NOT  NULL    NULL   ALTER  TABLE   SET  DEFAULT  UPDATE
       [update(7)]   null null  SET NOT NULL

       DROP COLUMN   SQL  NULL   UPDATE vacuum

       UPDATE table SET col = col;
       VACUUM FULL table;

          ALTER TABLE ONLY

        DROP COLUMN   DROP COLUMNALTER TABLE ONLY ... DROP COLUMN

        CREATE TABLE  Chapter 5 ``Data Definition''

EXAMPLES

         varchar

       ALTER TABLE distributors ADD COLUMN address varchar(30);

       ALTER TABLE distributors DROP COLUMN address RESTRICT;

       ALTER TABLE distributors RENAME COLUMN address TO city;

       ALTER TABLE distributors RENAME TO suppliers;

       ALTER TABLE distributors ALTER COLUMN street SET NOT NULL;

       ALTER TABLE distributors ALTER COLUMN street DROP NOT NULL;

       ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5);

       ALTER TABLE distributors DROP CONSTRAINT zipchk;

       ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses (address) MATCH FULL;

       ALTER TABLE distributors ADD CONSTRAINT dist_id_zipcode_key UNIQUE (dist_id, zipcode);

       ALTER TABLE distributors ADD PRIMARY KEY (dist_id);

COMPATIBILITY

       ADD COLUMN  SQL   NOT NULL  ALTER COLUMN

        / PostgreSQL   SQL

       ALTER TABLE DROP COLUMN   SQL

       Postgresql  <laser@pgsqldb.org>