Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW DO I ENFORCE A DEFUALT CONSTRAINT IN ORACLE

Status
Not open for further replies.

2314

Programmer
May 19, 2001
69
IN
HOW DO I ENFORCE A DEFUALT CONSTRAINT IN ORACLE
 
2314,

First, "DEFAULT" is not a constraint. "DEFAULT" is a "data directive" upon INSERT. It means if there is no value for a column for which you define a DEFAULT value, then Oracle applies that value to the receiving field upon INSERT.

Here is an example:
Code:
create table tab2314 (id number, create_date date default sysdate);

Table created.

insert into tab2314 (id) values (1);

1 row inserted.

select * from tab2314;

        ID CREATE_DA
---------- ---------
         1 15-NOV-04

1 row selected.

Notice that I provided no value for CREATE_DATE, yet it holds today's date as a result of the "DEFAULT SYSDATE" specification.

Does this answer your question?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
e-mail: dave@dasages.com
@ 06:06 (16Nov04) UTC (aka "GMT" and "Zulu"),
@ 23:06 (15Nov04) Mountain Time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top