Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Default column values

Re: Default column values

From: sach <sach_at_relex.ru>
Date: Mon, 23 Oct 2000 16:20:24 +0300
Message-ID: <8t1dq7$np9$1@mail.relex.ru>

oradba_n_az_at_my-deja.com ÐÉÛÅÔ × ÓÏÏÂÝÅÎÉÉ <8sq57p$kjs$1_at_nnrp1.deja.com> ...
>I have a test table with a date column, a
>varchar2 column and a number column with a
>default value of 50. When I insert data into the
>table and leave the number field blank (NULL), it
>stays NULL (doesn't insert the default value of
>50). If I modify the column to be NOT NULL and
>try to insert the same data, I violate the NOT
>NULL constraint. How does the default value get
>inserted into the table when no value is given in
>the insert statement?
>

By example, in DBMS Linter (Russua):
 create table test (d date, v varchar(2), n number default 50);

insert into test(d,v,n) values (to_date ('23.09.2000','dd.mm.yyyy'),'1',56);
insert into test(d,v) values (to_date ('23.09.2000','dd.mm.yyyy'),'2');
insert into test(d,v,n) values (to_date

('23.09.2000','dd.mm.yyyy'),'3',NULL);
insert into test(d,v,n) values (to_date ('23.09.2000','dd.mm.yyyy'),'4',59); insert into test default values;

select * from test;

|23.09.2000            |1 |                   56.0         |
|23.09.2000            |2 |                   50.0         |
|23.09.2000            |3 |                   <null>       |
|23.09.2000            |4 |                   59.0         |
|<null                        |<null> |           50.0         |
Received on Mon Oct 23 2000 - 08:20:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US