ORACLE to_char函数详解
The following are number examples for the to_char
function.
to_char
(1210.73,
'9999.9')
would return '1210.7'
to_char
(1210.73,
'9,999.99')
would return '1,210.73'
to_char
(1210.73,
'$9,999.00')
would return
'$1,210.73'
to_char
(21,
'000099')
would return '000021'
The following is a list of valid parameters when the to_char
function is used to convert a date to a string. These parameters can be
used in many combinations.
Parameter
Explanation
YEAR
Year, spelled out
YYYY
4-digit year
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
IYY
IY
I
Last 3, 2, or 1 digit(s) of ISO year.
IYYY
4-digit year based on the ISO standard
Q
Quarter of year (1, 2, 3, 4; JAN-MAR = 1).
MM
Month (01-12; JAN = 01).
MON
Abbreviated name of month.
MONTH
Name of month, padded with blanks to length of 9
characters.
RM
Roman numeral month (I-XII; JAN = I).
WW
Week of year (1-53) where week 1 starts on the first
day of the year and continues to the seventh day of the year.
W
Week of month (1-5) where week 1 starts on the first
day of the month and ends on the seventh.
IW
Week of year (1-52 or 1-53) based on the ISO
standard.
D
Day of week (1-7).
DAY
Name of day.
DD
Day of month (1-31).
DDD
Day of year (1-366).
DY
Abbreviated name of day.
J
Julian day; the number of days since January 1, 4712
BC.
HH
Hour of day (1-12).
HH12
Hour of day (1-12).
HH24
Hour of day (0-23).
MI
Minute (0-59).
SS
Second (0-59).
SSSSS
Seconds past midnight (0-86399).
FF
Fractional seconds.
The following are date examples for the to_char
function.
to_char
(sysdate,
'yyyy/mm/dd');
would return
'2003/07/09'
to_char
(sysdate,
'Month DD, YYYY');
would return 'July 09,
2003'
to_char
(sysdate,
'FMMonth DD, YYYY');
would return 'July 9,
2003'
to_char
(sysdate,
'MON DDth, YYYY');
would return 'JUL 09TH,
2003'
to_char
(sysdate,
'FMMON DDth, YYYY');
would return 'JUL 9TH,
2003'
相关文档:
sql*plus 命令
//执行脚本
@和start d:/a.txt;
//修改脚本
edit d:/a.txt;
//将内容输入到文本中
sloop d:/a.txt; //开始记录屏幕内容
sloop off; //记录结束
//链接登录数据库
connect system/919959 as sysdba/sysoper; //权限最大dba
connect sys/919959;
connect scott/ti ......
Oracle安装篇
版本:win32_11gR1_database_1013
系统:win7
内存:3g(偶自己地-0-)
1、因为操作系统选择了win7,所以在安装之选需要修改一下配置文件,database\stage\prereq\db\refhost.xml
2、修改完配置文件后,点install安装即可,等dos界面加载完后跳出如下界面
3、下一步
4、选择企业版,然后 ......
1,oracle tools:OUI、DBCA、OEM、SQL*PLUS、NETCA、第三方工具(toad、PL\SQL developer)
2,可使用responsefile快速去图形安装oracle,在源安装文件/response里面有一些模板配置rps文件
3,预置用户是sys用户与system用户:sys是oracle数据库
中权限最高的帐号,具有create
database的权限,而system没有这个权限� ......
Oracle中的存储过程和游标:
select myFunc(参数1,参数2..) to dual; --可以执行一些业务逻辑
一:Oracle中的函数与存储过程的区别:
A:函数必须有返回值,而过程没有.
B:函数可以单独执行.而过程必须通过execute执行.
C:函数可以嵌入到SQL语句中执行.而过程不行.
其实我们可以将比较复杂的查询写成函数.然后到存储过程 ......
对于rownum来说它是oracle系统顺序分配为从查询返回的行的编号,返回的第一行分配的是1,第二行是2,依此类推,这个伪字段可以用于限制查询返回的总行数,而且rownum不能以任何表的名称作为前缀。
举例说明:
例如表:student(学生)表,表结构为:
ID char(6) --学号
name ......