Oracle创建带有自增序列的表和字符串转日期的问题

创建Oracle表的sql语句如下:

--创建tm_product
create table tm_product(
       pid number(8) primary key not null,productId number(20)  not null,productName varchar2(500) not null,price number(10) not null,upTime date not null,downTime date not null,remark varchar2(500)
 );
--说明
comment on table tm_product is '产品表';
comment on column tm_product.pid is '主键ID';
comment on column tm_product.productId is '产品ID';
comment on column tm_product.productName is '产品名称';
comment on column tm_product.price is '低消金额(元)';
comment on column tm_product.upTime is '上架时间';
comment on column tm_product.downTime is '下架时间';
comment on column tm_product.remark is '说明';
--创建序列
create sequence seq_tm_product
minvalue 1
nomaxvalue
start with 1
increment by 1
nocycle   --一直累加,不循环
--nocache;  --不缓存
cache 10; --缓存10条
--创建触发器,如果insert语句不指定ID自动插入增长值
CREATE OR REPLACE TRIGGER tr_tm_product
BEFORE INSERT ON tm_product FOR EACH ROW WHEN (new.pid is null)
begin
select seq_tm_product.nextval into:new.pid from dual;
end;

在这里日期转换是个问题,即在后代如何将字符串变成日期格式呢,我在sql语句做文章
INSERT INTO tm_product(productId,productName,price,upTime,downTime,remark) VALUES (?,?,to_date(?,'YYYY-MM-dd'),?)
不然在后台很容易出现 java.sql.Date和java.util.Date的冲突!

相关文章

Java Oracle 结果集是Java语言中处理数据库查询结果的一种方...
Java AES和Oracle AES是现代加密技术中最常使用的两种AES加密...
Java是一种广泛应用的编程语言,具备可靠性、安全性、跨平台...
随着移动互联网的发展,抽奖活动成为了营销活动中不可或缺的...
Java和Oracle都是在计算机领域应用非常广泛的技术,他们经常...
Java 是一门非常流行的编程语言,它可以运行于各种操作系统上...