数据库
首页 > 数据库> > Oracle date类型的相关处理函数

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;

转自:https://blog.csdn.net/paullinjie/article/details/80615310

标签:insert,20,date,xx,varchar2,datecol,Oracle,处理函数
来源: https://blog.csdn.net/qq_40778551/article/details/94162688