dynamicjourney2001
Programmer
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
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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