Override the defaults by specifying a value for the columns : Column Default Value « Table « Oracle PL / SQL






Override the defaults by specifying a value for the columns

   

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, status, last_modified)
  2                    VALUES (2, 'Order shipped', to_date('19960917','YYYYMMDD'));

1 row created.

SQL>
SQL>
SQL> SELECT * FROM order_status;

ORDER_STATUS_ID STATUS               LAST_MODIFI
--------------- -------------------- -----------
              2 Order shipped        1996-SEP-17

SQL>
SQL> drop table order_status;

Table dropped.

SQL>
           
         
    
    
  








Related examples in the same category

1.Create table with column having the default value
2.column with default as sysdate
3.Use rpad to fill default value to a column
4.null with default value column
5.Default char value
6.Default varchar value
7.Use char function to build default column value