Subscribe Search to Oracle-life
Subscribe
Via RSS By RSS
Via Mail By Mail

Saturday, May 23, 2009

Default Value of Oracle

A column can be given a default value by using DEFAULT option. If any table has DEFAULT options enabled, then it specify a default value far a column during data or value inserting time.

Example:

Let, we have a table and there is a column named as hire_date which insert values automatically when we give an entry of a particular user or employee. Here the automatic column is hire_date which automatically insert the system date (SYSDATE) to the hire_date column of the table.
  • ...... hire_date DATE DEFAULT SYSDATE, .....

Allowable DEFAULT values:
A default value can be one of the followings:
  • literal values
  • expression
  • SQL function
  • Example: SYSDATE, USER etc.
Non-allowable DEFAULT values:
A default value can't be the followings:
  • another column's name
  • pseudocode
  • Example: NEXTVAL, CURRVAL, ROWNUM etc.
Note:
A default expression must match the data type of the current column.

No comments:

Post a Comment