Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: how to modify a CHECK column-constrait ?

Re: how to modify a CHECK column-constrait ?

From: Brian Peasland <peasland_at_email.msn.com>
Date: Fri, 23 Jul 1999 20:51:52 -0500
Message-ID: <en9hlcX1#GA.350@cpmsnbbsa05>

>>> I've found 2 annoying problems. According to the SQL Reference Manual
>>> (Oracle 7.3 and 8.0) it is not possible to:
>>> 1. modify an existing CHECK column-constraint;
>>> 2. drop a column from a table;

  1. To modify an existing CHECK constraint, it's as easy as dropping the constraint and then altering the table to include the new CHECK constraint you'd like. True, you can't modify the constraint directly,but this other method isn't that difficult.
  2. Dropping a column from a table is something everyone wishes to be possible. Apparently Oracle is listening since this feature is available with Oracle 8i (8.1.5). But once again, there is a workaround. This one takes a little more effort. Assuming table 1 has columns col1, col2, col3, you can do one of two things:
    1. copy the table to a temp table: CREATE table1_copy AS SELECT * FROM table1. Then drop the table: DROP TABLE table1. Then recreate the new table without col2: CREATE TABLE table1 AS SELECT col1, col3 FROM table1_copy. Now drop the temp table: DROP TABEL table1_copy.

   Or

   b) Just create a view that only has the two columns: CREATE VIEW table1_view AS SELECT col1,col3 FROM table1.

Hope that helps,
Brian Peasland
peasland_at_msn.com Received on Fri Jul 23 1999 - 20:51:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US