看个例子就明白了
[php]
SQL> create table toms(date_str varchar2(10),
2time_str varchar2(8),
3id varchar2(20));
表已创建。
SQL> insert into toms values('2006/05/05','10:10:10','2006/05/050600220');
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from toms;
2006/05/05 10:10:10 2006/05/050600220
SQL> select *from toms where id='2006/05/050600220';
2006/05/05 10:10:10 2006/05/050600220
SQL> select * from toms where id='2006/05/050600220' and to_date(date_str||' '||time_str,'yyyy/mm/dd
hh24:mi:ss') = to_date('2006/05/05 10:10:10','yyyy/mm/dd hh24:mi:ss');
2006/05/05 10:10:10 2006/05/050600220
SQL> insert into toms values(null,null,'2006/05/050600220');
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from toms where id='2006/05/050600220' and to_date(date_str||' '||time_str,'yyyy/mm/dd
hh24:mi:ss') = to_date('2006/05/05 10:10:10','yyyy/mm/dd hh24:mi:ss');
ERROR:
ORA-01841: (完整) 年份值必须介于 -4713 和 +9999 之间, 且不为 0
未选定行
SQL> select * from toms;
2006/05/05 10:10:10 2006/05/050600220
2006/05/050600220
SQL>
[/php]
|