oracle中建立一个表,其中一个字段为date,当咱们进行插入操做编程
1 create table xf_allsalestotal 2 ( 3 xf_txdate date not null, 4 xf_storecode varchar(20) not null, 5 xf_storename varchar(50) not null, 6 xf_clothes number(16,4) default(0), 7 xf_craft number(16,4) default(0) , 8 xf_jewelry number(16,4) default(0), 9 xf_totalsale number(16,4) default(0) 10 )
1 insert into xf_allsalestotal(xf_txdate,xf_storecode,xf_storename,xf_clothes,xf_craft,xf_jewelry) 2 values(sysdate,'SZ01','深圳店',1000,2000,30000);
获得的结果是这样oracle
若是咱们不须要后面的时间只须要日期的话,一种就是经过to_char(sysdate,'YYYY/MM/DD') 编程字符串,可是在咱们这个例子中函数
xf_txdate中date类型,显然不合适;咱们采起另外一种方法,直接经过trunc函数,就直接能够达到这个效果
1 insert into xf_allsalestotal(xf_txdate,xf_storecode,xf_storename,xf_clothes,xf_craft,xf_jewelry) 2 values(trunc(sysdate),'SZ01','深圳店',1000,2000,30000);