日期:2014-05-16  浏览次数:20525 次

数据库插入数据

?

?

?

插入数据库的时候,加入定义如下:

?

create table plant(plantid number(9),name varchar2(300),createdate date default sysdate)

?

?

如果用下面语句插入:

?

insert into plant(plantid,name) values(2,'moli',null);

?

结果出现

?

plantid | ?name| createdate

?? ? ? ? ? ?| ? ? ? ? ? |

?? ?2 ? ? ? ? ? moli ? ? ? ? ? ? ? ? ? ? ?

?

?

但是用下面语句插入:

?

insert into plant(plantid,name) values(2,'moli');

?

或者

?

insert into plant(plantid,name,createdate) values(2,'moli',default);

?

?

结果出现

?

plantid | ?name| createdate

?? ? ? ? ? ?| ? ? ? ? ? |

?? ?2 ? ? ? ? ? moli ? ? ?2011-3-30 10:09:42

?

?

意思,就是表中的默认值,有default value的可以不填写这个字段,但是不能写了这个字段,又填空。 ??

?

?

?