Search

DEFAULT




Default can be considered as a substitute behavior of not null constraint when applied to new rows being entered into the table.
When you define a column with the default keyword followed by a value, you are actually telling the database that, on insert if a row was not assigned a value for this column, use the default value that you have specified.
Default is applied only during insertion of new rows.

Ex:
     SQL> create table student12(no number(2) default 11,name varchar(2));
     SQL> insert into student12 values(1,'a');
     SQL> insert into student12(name) values('b');
    
     SQL> select * from student12;

        NO   NAME
      ------ ---------
         1             a
        11            b

       SQL> insert into student12 values(null, ‘c’);

      SQL> select * from student12;

        NO   NAME
      ------ ---------
         1             a
        11            b
                     C
-- Default can not override nulls.