ORACLE插入日期数据
oracle数据库插入日期型数据
往Oracle数据库中插入日期型数据(to_date的用法)
INSERT INTO FLOOR VALUES ( to_date ( '2007-12-20 18:31:34' , 'YYYY-MM-DD HH24:MI:SS' ) ) ;
查询显示:2007-12-20 18:31:34.0
-------------------
INSERT INTO FLOOR VALUES ( to_date ( '2007-12-14 14:10' , 'YYYY-MM-DD HH24:MI' ) );
查询显示:2007-12-14 14:10:00.0
-------------------
INSERT INTO FLOOR VALUES ( to_date ( '2007-12-14 14' , 'YYYY-MM-DD HH24' ) );
查询显示:2007-12-14 14:00:00.0
-------------------
INSERT INTO FLOOR VALUES ( to_date ( '2007-11-15' , 'YYYY-MM-DD' ) );
查询显示:2007-11-15 00:00:00.0
-------------------
INSERT INTO FLOOR VALUES ( to_date ( '2007-09' , 'YYYY-MM' ) );
查询显示:2007-09-01 00:00:00.0
-------------------
INSERT INTO FLOOR VALUES ( to_date ( '2007' , 'YYYY' ) );
查询显示:2007-05-01 00:00:00.0
-------------------
当省略HH、MI和SS对应的输入参数时,Oracle使用0作为DEFAULT值。
如果输入的日期数据忽略时间部分,Oracle会将时、分、秒部分都置为0,也就是说会取整到日。
同样,忽略了DD参数,Oracle会采用1作为日的默认值,也就是说会取整到月。
但是,不要被这种“惯性”所迷惑,如果忽略MM参数,Oracle并不会取整到年,而是取整到当前月
相关文档:
Oracle的约束
* 如果某个约束只作用于单独的字段,即可以在字段级定义约束,也可以在表级定义约束,但如果某个约束作用于多个字段,
必须在表级定义约束
* 在定义约束时可以通过CONSTRAINT关键字为约束命名,如果没有指定,ORACLE将自动为约束建立默认的名称
定义primary key约束(单个字段)
create table ......
今天XXX说要把Oracle 里的几张表重新整理下,呵呵 结果阿发现10来张表还真是说多不多说少一点都不少 。因为表里面的commet已经填上了 。偷懒的想法顿时出现嘎嘎
select t.COLUMN_NAME 字段名, t.DATA_TYPE||'('||t.DATA_LENGTH||')' 字段类型,t.NULLABLE 是否为空,t.DATA_DEFAULT 默认值,p.comments 字段说明
fro ......
As you may know, Oracle dropped support for Borland Compilers in OCI
some time back. Well, it isn't all that hard to set up again.
I'm running 9i Release 2 Enterprise Edition on this PC at work and I am
using Borland C++ Builder 6 to 'play' with OCI programming - I intend to
build a set of compo ......
select t.*, t.rowid from indicators t start with (t.isleaf='1' and t.rid='26020')
connect by prior t.pid = t.id order by t.inum
从叶子节点依据id=pid的关系向上递归到跟节点。
select t.*, t.rowid from indicators t start with (t.pid='0' and t.rid='26020')
connect by prior t.id = t.pid order by t.i ......