You can update a column and set it back to the default using the DEFAULT keyword in an UPDATE statement
SQL>
SQL> --You can update a column and set it back to the default using the DEFAULT keyword in an UPDATE statement
SQL>
SQL> CREATE TABLE order_status (
2 order_status_id INTEGER,
3 status VARCHAR2(20) DEFAULT 'Order placed' NOT NULL,
4 last_modified DATE DEFAULT SYSDATE
5 );
Table created.
SQL>
SQL>
SQL> --Override the defaults by specifying a value for the columns
SQL>
SQL> INSERT INTO order_status (order_status_id)
2 VALUES (2);
1 row created.
SQL>
SQL>
SQL>
SQL>
SQL> SELECT * FROM order_status;
ORDER_STATUS_ID STATUS LAST_MODIFI
--------------- -------------------- -----------
2 Order placed 2006-SEP-17
SQL>
SQL> UPDATE order_status
2 SET status = DEFAULT
3 WHERE order_status_id = 2;
1 row updated.
SQL>
SQL> SELECT * FROM order_status;
ORDER_STATUS_ID STATUS LAST_MODIFI
--------------- -------------------- -----------
2 Order placed 2006-SEP-17
SQL>
SQL> drop table order_status;
Table dropped.
SQL>
SQL>
Related examples in the same category