Index: alter_table.sgml =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v retrieving revision 1.24 diff -c -r1.24 alter_table.sgml *** alter_table.sgml 2001/05/09 13:27:15 1.24 --- alter_table.sgml 2001/05/30 04:16:19 *************** *** 38,43 **** --- 38,45 ---- RENAME TO newtable ALTER TABLE table ADD table constraint definition + ALTER TABLE [ ONLY ] table + DROP CONSTRAINT constraint { RESTRICT | CASCADE } ALTER TABLE table OWNER TO new owner *************** *** 177,182 **** --- 179,186 ---- The ADD table constraint definition clause adds a new constraint to the table using the same syntax as . + The DROP CONSTRAINT constraint clause + drops all CHECK constraints on the table (and its children) that match constraint. The OWNER clause changes the owner of the table to the user new user. *************** *** 208,218 **** In the current implementation, only FOREIGN KEY and CHECK constraints can ! be added to a table. To create or remove a unique constraint, create a unique index (see ). You must own the table in order to change it. Changing any part of the schema of a system --- 212,242 ---- In the current implementation, only FOREIGN KEY and CHECK constraints can ! be added to a table. To create a unique constraint, create a unique index (see ). + + Currently only CHECK constraints can be dropped from a table. The RESTRICT + keyword is required, although dependencies are not checked. The CASCADE + option is unsupported. To remove a PRIMARY or UNIQUE constraint, drop the + relevant index using the command. + To remove FOREIGN KEY constraints you need to recreate + and reload the table, using other parameters to the + + command. + + + For example, to drop all constraints on a table distributors: + + CREATE TABLE temp AS SELECT * FROM distributors; + DROP TABLE distributors; + CREATE TABLE distributors AS SELECT * FROM temp; + DROP TABLE temp; + + + You must own the table in order to change it. Changing any part of the schema of a system *************** *** 261,266 **** --- 285,297 ---- + To remove a check constraint from a table and all its children: + + ALTER TABLE distributors DROP CONSTRAINT zipchk + + + + To add a foreign key constraint to a table: ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses(address) MATCH FULL *************** *** 289,322 **** statement which are not yet directly supported by Postgres: - - - - ALTER TABLE table DROP CONSTRAINT constraint { RESTRICT | CASCADE } - - - - - Removes a table constraint (such as a check constraint, - unique constraint, or foreign key constraint). To - remove a unique constraint, drop a unique index. - To remove other kinds of constraints you need to recreate - and reload the table, using other parameters to the - - command. - - - For example, to drop any constraints on a table distributors: - - CREATE TABLE temp AS SELECT * FROM distributors; - DROP TABLE distributors; - CREATE TABLE distributors AS SELECT * FROM temp; - DROP TABLE temp; - - - - - --- 320,325 ----