Oracle Date Function 讲解和事例
http://blog.csdn.net/mustbelove/archive/2007/04/17/1567836.aspx(转)
1 year=1*12 months
1 day=24
hours=24*(1*60mins)=24*60*(1*60 seconds)
1 week =7 days
注意:
黑色字体是 oracle
8i,9i都可以使用的函数,
蓝色字体是 Oracle
9i
新
增的部分。
请大家在使用时,注意版本限制。
add_months
current_date
current_timestamp
datimezone
extract(datetime)
last_day
months_between
new_time
next_day
round
SYSDATE
systimestamp
TO_DATE
trunc()
1: Add_Months
语法:
Add_Months(d,n)
函数 -- n可正可负
作用: Add_Months(d,n) 返回日期 D 加上n
月的日期
Example:
A:下个月的今天
select add_months(sysdate,1) from
dual --在月份上增加
B:上个月的今天
select add_months(sysdate,-1) from dual
--在月份上减少
C: 上个月的最后一天
select last_day(add_months(sysdate,-1)) from
dual
2: C
urrent_date
语法:
C
urrent_date
作用:
CURRENT_DATE 返回当前Session 时区的当前日期。
Example:
A:不特别设定 oracle
time_zone 是和系统Time_zone 一致。
select current_date,sysdate from dual
SQL> select
current_date,sysdate from dual ;
CURRENT_DATE
SYSDATE
--------------- ---------------
20051109 160535 20051109
160534
B:
ALTER SESSION SET TIME_ZONE = '-5:0';
SQL> select current_date,sysdate from
dual;
CURRENT_DATE SYSDATE
---------------
---------------
20051109 030644
20051109 160644
3: C
urrent_timestamp
语法:
CURRENT_TIMESTAMP
(precision)
作用:
current_timestamp
返回此session 所在时区的当前日期和时间。
数据类型是 TIMESTAMP
WITH TIME ZONE.
Example:
A:default
timestamp
SQL> select CURRENT_TIMESTAMP
from dual;
CURRENT_TIMESTAMP
------------------------------------------------------------
09-NOV-05
04.27.41.416811 PM +08:00
B: use precision
SQL> ALTER
SESSION SET TIME_ZONE ='-5:0';
Session altered.
SQL> SELECT
SESSIONTIMEZONE, CURRENT_TIMESTAMP
from DUAL
SESSIONTIMEZONE CURRENT_TIMESTAMP
--------------------
---------------------------------------
-05:00 09-NOV-0
相关文档:
http://inthirties.com:90/thread-918-3-1.html
This article describes the installation of
Oracle 10g release 2 (10.2.0.1) RAC on Linux (Oracle Enterprise Linux
4.5) using NFS to provide the shared storage.
Introduction
Download Software
Operating System Installation
Oracle Installation Prereq ......
关键字: oracle数据库
Oracle数据库命令集
1、sqlplus启动方式:
Dos下运行sqlplus 用户名/密码 as sysdba
例如:c:>sqlplus sys/password AS sydba(系统帐户)
或者:c:>sqlplus scott/password
2、用户连接(切换)操作:
sql>conn Scott/password(默认为tiger)
注:conn与connect使用方法一 ......
在 Oracle 中,对于已经建好的主键,是自动创建索引的,并且索引是创建到当前的表空间中的,如果要将索引更换到其它表空间,可以使用如下的方法,超简单:
alter index index_aaa rebuild tablespace newtablespace;
newtablespace 是新指定的表空间。 ......
1 目的
规范数据库各种对象的命名规则。
2 数据库命名原则
2.1 数据文件
如果数据库采用文件系统,而不是裸设备,约定下列命名规则:
1)数据文件以表空间名为开始,以.dbf为结尾,全部采用小写英文字母加数字命名。如该表空间有多个数据文件,则从第2个数据文件开始,在表空间名后加_。
例:对system表空间的数 ......
/******************************************************************************/
/*
主流数据库MYSQL/MSSQL/ORACLE测试数据库脚本代码
脚本任务:建立4个表,添加主键,外键,插入数据,建立视图
运行环境1:microsoft sqlserver 2000 查询分析器
运行环境2:mysql5.0 phpMyAdmin网页界面
运行环境3:oracle 9i SQL*P ......