oracle中如何插入date类型的数据

oracle中如何插入date类型的数据方法如下:

insert into tabname(datecol) value(sysdate) ;  -- 用date值

insert into tabname(datecol) value(sysdate+1) ;  -- 用date值

insert into tabname(datecol) value(to_date('2014-02-14','yyyy-mm-dd')) ;  -- 用to_date

insert into tabname(datecol) value(to_date('2014-02-14 20:47:00','yyyy-mm-dd hh24:mi:ss')) ;  -- 用to_date

insert into tabname(datecol) value(to_date('20140214','yyyymmdd')) ;  -- 用to_date

insert into tabname(datecol) value(to_date('20140214204700','yyyymmddhh24miss')) ;  -- 用to_date


select table_name,tablespace_name from user_tables where table_name='EMP';
drop table EMP;
create table EMP
(
EMPNO NUMBER(6) not null unique,
ENAME varchar2(20),
JOB varchar2(20),
MGR varchar2(20),
HIREDATE date,
SAL varchar2(20),
COMM varchar2(20),
DEPTNO varchar2(20)

);


INSERT INTO EMP VALUES(44449, '小明', '工程师', 'ligang', 
to_date('20140214204700','yyyymmddhh24miss'), '1000', '12345', 'test');

commit;


select xx.empno,xx.ename,xx.job,xx.mgr,xx.hiredate,xx.sal,xx.comm,xx.deptno
from (select rownum id1,emp.* from emp where rownum<4) xx
where id1>0;


展开阅读全文

没有更多推荐了,返回首页