Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to remove 'default' definition of a column.

Status
Not open for further replies.

dynamicjourney2001

Programmer
May 15, 2003
30
US

hi guys,
how can i remove or undo a default value for a column that was defined during creation of the table without deleting datas from the column.

have fun!
Dynamic
 
Dynamic,

Should not be a big problem .Try

Code:
scott@MYDB.WORLD> CREATE TABLE test_default (id NUMBER NOT NULL PRIMARY KEY, town VARCHAR2(30) DEFAULT 'London' NULL);

Table created.

scott@MYDB.WORLD> INSERT INTO test_default (id) VALUES (1);

1 row created.

scott@MYDB.WORLD> INSERT INTO test_default VALUES (2, 'New York');

1 row created.

scott@MYDB.WORLD> INSERT INTO test_default VALUES (3, DEFAULT);

1 row created.

scott@MYDB.WORLD> SELECT * FROM test_default;

        ID TOWN
---------- ------------------------------
         1 London
         2 New York
         3 London
-- Now I am removing default from town column by redefining the DEFAULT clause with a NULL values.

  1* ALTER TABLE test_default MODIFY TOWN DEFAULT NULL
scott@MYDB.WORLD> /

Table altered.

scott@MYDB.WORLD> INSERT INTO test_default (id) VALUES (4);

1 row created.

scott@MYDB.WORLD> SELECT * FROM  test_default;

        ID TOWN
---------- ------------------------------
         1 London
         2 New York
         3 London
         4

Hope this helps


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top