- 浏览: 1020303 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (529)
- 服务器 (8)
- jsp (1)
- java (6)
- AIX (1)
- solaris (3)
- linux学习 (53)
- javaScript (2)
- hibernate (1)
- 数据库 (74)
- sql语句 (8)
- oracle 学习 (75)
- oracle 案例 (42)
- oracle 管理 (42)
- Oracle RAC (27)
- oracle data guard (12)
- oracle 参数讲解 (14)
- Oracle 字符集 (8)
- oracle性能调优 (24)
- oracle备份与恢复 (12)
- oracle Tablespace (9)
- oracle性能诊断艺术 (1)
- oracle 11g学习 (5)
- oracle streams (1)
- oracle upgrade and downgrade (4)
- db2学习 (13)
- db2命令学习 (2)
- mysql (28)
- sql server (30)
- sql server 2008 (0)
- 工具 (10)
- 操作系统 (3)
- c++ (1)
- stock (1)
- 生活 (5)
- HADOOP (2)
最新评论
-
massjcy:
...
如何将ubuntu文件夹中文名改为英文 -
skypiea:
谢谢。。。
终于解决了。。。
Oracle 10.2.0.4(5)EM不能启动的解决方案(Patch 8350262) -
qwe_rt:
引用vi /etc/sysconfig/network 请问 ...
Linux操作系统下配置静态IP上网 -
liuqiang:
sudo killall -9 apache2
ps 和 kill 命令详解 -
dazuiba:
引用*绝杀 kill -9 PID 当使用此命令时,一定要通过 ...
ps 和 kill 命令详解
1、字符函数
lower:把字符转成小写
upper:把字符转成大写
initcap:把单词的第一个字母变成大写
concat:连接字符 concat(‘good’,’morning’)=goodmoring
SUBSTR (columnexpression, m[,n]) 用于对字符串进行截取操作,从第m 个位置开始,把其后的连续n个字符的部分截取下来,如果m位负值,则从末尾开始计算。
eg:substr(‘string’,1,3) =str
substr(‘string’-3,3)=ing
INSTR('String', 'r')=3
LPAD(sal,10,'*') =*******sal RPAD()
length: 用于返回表达式中的字符数,注意返回的是NUMBER。
NVL(expression1, expression2)
NVL 函数用以把一个空值转换为一个实值,如:
NVL(100/quantity, 0) ,要是quantity 为空值,该函数返回一个0。
2、数学函数
round:四舍五入
round(2.566,2)=2.27
round(45,-1)=50
trunc: 截断
trunc(2.566,2)=2.56
trunc(45,-1)=40
mod: mod(m,n)
floor(m/n),ceil(m/n)
3、日期函数:
a) months_between(date1,date2):算date1 和date2 之间的月的数量,可以是小数可以是负数
months_between(’01-sep-95’,’11-jan-94’)=1.9774194
b) add_months(date,n):为date 加上N 个月,N 只可以是整数
c) next_date(date,’char’):查找date 的下一个星期Nnext_date(’01-sep-95’,’FRIDAY’)=08-SEP-95
d) last_day(date):查找date 月的最后一天。
e) round(date):把日期四舍五入
f) round(25-MAY-95’,’MONTH’)=01-JUN-95
g) round(25-MAY-95’,’YEAR’)=01-JAN-95
h) trunc(date):把日期截断
i) trunc (25-MAY-95’,’MONTH’)=01-MAY-95
j) trunc (25-MAY-95’,’YEAR’)=01-JAN-95
4、转换函数
TO_CHAR:
TO_CHAR(date,’fmt’):fm前缀用来去除首尾的空字符或0
TO_CHAR(total,’fm$999999’)
如果想转成$0.25,那就要写成fm$9999990.99
to_char(1234,’09999’)
可以把日期转换成字符
TO_CHAR(log_time,’MM/YY’)
SELECT to_char(SYSDATE,'yyyy"年"mm"月"dd"日"') FROM dual
具体格式如下
Number Format Elements Results of Number Conversionshttp://xsb.itpub.net/post/419/31722
, (comma) |
|
Returns a comma in the specified position. You can specify multiple commas in a number format model. Restrictions:
|
. (period) |
|
Returns a decimal point, which is a period (.) in the specified position. Restriction: You can specify only one period in a number format model. |
$ |
|
Returns value with a leading dollar sign. |
0 |
|
Returns leading zeros. Returns trailing zeros. |
9 |
|
Returns value with the specified number of digits with a leading space if positive or with a leading minus if negative. Leading zeros are blank, except for a zero value, which returns a zero for the integer part of the fixed-point number. |
B |
|
Returns blanks for the integer part of a fixed-point number when the integer part is zero (regardless of zeros in the format model). |
C |
|
Returns in the specified position the ISO currency symbol (the current value of the |
D |
|
Returns in the specified position the decimal character, which is the current value of the Restriction: You can specify only one decimal character in a number format model. |
EEEE |
|
Returns a value using in scientific notation. |
G |
|
Returns in the specified position the group separator (the current value of the Restriction: A group separator cannot appear to the right of a decimal character or period in a number format model. |
L |
|
Returns in the specified position the local currency symbol (the current value of the |
MI |
|
Returns negative value with a trailing minus sign (-). Returns positive value with a trailing blank. Restriction: The MI format element can appear only in the last position of a number format model. |
PR |
|
Returns negative value in <angle brackets>. Returns positive value with a leading and trailing blank. Restriction: The PR format element can appear only in the last position of a number format model. |
RN rn |
|
Returns a value as Roman numerals in uppercase. Returns a value as Roman numerals in lowercase. Value can be an integer between 1 and 3999. |
S |
|
Returns negative value with a leading minus sign (-). Returns positive value with a leading plus sign (+). Returns negative value with a trailing minus sign (-). Returns positive value with a trailing plus sign (+). Restriction: The S format element can appear only in the first or last position of a number format model. |
TM |
|
The text minimum number format model returns (in decimal output) the smallest number of characters possible. This element is case insensitive. The default is TM9, which returns the number in fixed notation unless the output exceeds 64 characters. If the output exceeds 64 characters, then Oracle Database automatically returns the number in scientific notation. Restrictions:
|
U |
|
Returns in the specified position the Euro (or other) dual currency symbol (the current value of the |
V |
|
Returns a value multiplied by 10n (and if necessary, round it up), where |
X |
|
Returns the hexadecimal value of the specified number of digits. If the specified number is not an integer, then Oracle Database rounds it to an integer. Restrictions:
|
number
and 'fmt'
:
SELECT TO_CHAR(number, 'fmt')
FROM DUAL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Datetime Format Elements
-
/
,
.
;
:
"text"
|
Yes |
Punctuation and quoted text is reproduced in the result. |
AD
A.D.
|
Yes |
AD indicator with or without periods. |
AM
A.M.
|
Yes |
Meridian indicator with or without periods. |
BC
B.C.
|
Yes |
BC indicator with or without periods. |
CC
SCC
|
No |
Century.
For example, 2002 returns 21; 2000 returns 20. |
D
|
Yes |
Day of week (1-7). |
DAY
|
Yes |
Name of day, padded with blanks to display width of the widest name of day in the date language used for this element. |
DD
|
Yes |
Day of month (1-31). |
DDD
|
Yes |
Day of year (1-366). |
DL
|
Yes |
Returns a value in the long date format, which is an extension of Oracle Database's Restriction: You can specify this format only with the |
DS
|
Yes |
Returns a value in the short date format. Makes the appearance of the date components (day name, month number, and so forth) depend on the Restriction: You can specify this format only with the |
DY
|
Yes |
Abbreviated name of day. |
E
|
No |
Abbreviated era name (Japanese Imperial, ROC Official, and Thai Buddha calendars). |
EE
|
No |
Full era name (Japanese Imperial, ROC Official, and Thai Buddha calendars). |
FF [1..9]
|
Yes |
Fractional seconds; no radix character is printed (use the X format element to add the radix character). Use the numbers 1 to 9 after FF to specify the number of digits in the fractional second portion of the datetime value returned. If you do not specify a digit, then Oracle Database uses the precision specified for the datetime datatype or the datatype's default precision. Examples:
|
FM
|
Yes |
Returns a value with no leading or trailing blanks. See Also: Additional discussion on this format model modifier in the Oracle Database SQL Reference |
FX
|
Yes |
Requires exact matching between the character data and the format model. See Also: Additional discussion on this format model modifier in the Oracle Database SQL Reference |
HH
|
Yes |
Hour of day (1-12). |
HH12
|
No |
Hour of day (1-12). |
HH24
|
Yes |
Hour of day (0-23). |
IW
|
No |
Week of year (1-52 or 1-53) based on the ISO standard. |
IYY
IY
I
|
No |
Last 3, 2, or 1 digit(s) of ISO year. |
IYYY
|
No |
4-digit year based on the ISO standard. |
J
|
Yes |
Julian day; the number of days since January 1, 4712 BC. Number specified with J must be integers. |
MI
|
Yes |
Minute (0-59). |
MM
|
Yes |
Month (01-12; January = 01). |
MON
|
Yes |
Abbreviated name of month. |
MONTH
|
Yes |
Name of month, padded with blanks to display width of the widest name of month in the date language used for this element. |
PM
P.M.
|
No |
Meridian indicator with or without periods. |
Q
|
No |
Quarter of year (1, 2, 3, 4; January - March = 1). |
RM
|
Yes |
Roman numeral month (I-XII; January = I). |
RR
|
Yes |
Lets you store 20th century dates in the 21st century using only two digits. See Also: Additional discussion on |
RRRR
|
Yes |
Round year. Accepts either 4-digit or 2-digit input. If 2-digit, provides the same return as RR. If you do not want this functionality, then enter the 4-digit year. |
SS
|
Yes |
Second (0-59). |
SSSSS
|
Yes |
Seconds past midnight (0-86399). |
TS
|
|
Returns a value in the short time format. Makes the appearance of the time components (hour, minutes, and so forth) depend on the Restriction: You can specify this format only with the |
TZD
|
Yes |
Daylight savings information. The TZD value is an abbreviated time zone string with daylight savings information. It must correspond with the region specified in TZR. Example: |
TZH
|
Yes |
Time zone hour. (See Example: |
TZM
|
Yes |
Time zone minute. (See Example: |
TZR
|
Yes |
Time zone region information. The value must be one of the time zone regions supported in the database. Example: US/Pacific |
WW
|
No |
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
|
No |
Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh. |
X
|
Yes |
Local radix character. Example: |
Y,YYY
|
Yes |
Year with comma in this position. |
YEAR
SYEAR
|
No |
Year, spelled out; |
YYYY
SYYYY
|
Yes |
4-digit year; |
YYY
YY
Y
|
Yes |
Last 3, 2, or 1 digit(s) of year. |
发表评论
-
数据库设计规范
2011-11-24 10:40 6871数据库设计(Database Desi ... -
Linux下用OCCI或OCI连接Oracle
2011-07-26 12:00 2899首先,去oracle官网下载C ... -
PowerDesigner快捷键
2011-03-19 00:10 1098一般快捷键F4 打开检查模型窗口,检查模型F5 如果图 ... -
oracle和sql server功能对比
2011-01-05 22:05 1810Oracle Database 10g对比SQL Server ... -
Parse CPU to Parse Elapsd%的理解
2010-11-28 18:37 6760Parse CPU to Parse Elapsd%是指sql ... -
DB2客户端连接服务端的方法(转载)
2010-07-14 22:40 911在DB2中从客户端访问服 ... -
四大数据库的比较(SQL Server、Oracle、Sybase和DB2)
2010-07-14 21:54 1527本篇引用于公司数据库 ... -
Oracle迁移到DB2常用转换
2010-07-01 13:12 1150因为项目需要,要将Oracle上的东西转移到DB2,于是收集整 ... -
输出object的DDL的方法
2010-06-23 01:07 1426最近一段时间,由于经常要通过ssh访问远程环境。所以图形工具使 ... -
oracle的license和正版使用问题
2010-06-08 01:08 19411, 正版Oracle 产品和盗版的区别 直奔主题,这是许多研 ... -
oracle opatch 工具的使用(oracle小补丁安装)(转)
2010-05-30 13:49 2251从9.2版开始,Oracle公司设计实现了个别补丁安装管理工具 ... -
mysql常用函数
2009-12-29 10:25 951一、数学函数ABS(x) ... -
SP2-0618和_SP2-0611错误处理
2009-12-27 23:48 1067AUTOTRACE是一项 SQL*Plus 功能,自动跟踪为 ... -
几分钟学会Oracle Audit
2009-12-03 15:49 21591、什么是审计 简单来讲,就是把对数据库的操作记录下来。不管 ... -
alter system switch logfile和alter system archive log current的区别
2009-12-03 12:19 1107alter system switch logfile 是强制 ... -
由HWM引出的drop,delete,truncate的异同点比较
2009-12-02 14:18 1234今天在做HWM时,说truncate表后HWM会降低,但是dr ... -
主流数据库的比较
2009-12-02 10:29 1286开发数据库应用,选择一个好的数据库是非常重要的。目前, 商品 ... -
Oracle MTS相关问题
2009-09-09 22:34 1320Oracle MTS的相关问题 一、什么是MTS MTS ... -
10g: SYSAUX 里面都有些什么东西
2009-09-04 12:38 1828Isabella says:SYSAUX 暴涨有 ... -
ORACLE的PL/SQL一
2009-08-26 17:03 1147一、什么是PL/SQL? P ...
相关推荐
Oracle 常用函数大全 Oracle 中有许多常用函数,以下是其中一些: 字符函数 1. ASCII:返回与指定的字符对应的十进制数。例如:`SELECT ASCII('A') FROM DUAL;` 返回 65。 2. CHR:给出整数,返回对应的字符。...
Oracle常用函数大全 Oracle常用函数大全是一个非常重要的知识点,涵盖了许多实用的函数,例如日期函数、字符串函数、聚合函数等。这些函数可以帮助开发者更方便地进行数据库操作和数据分析。本文将详细介绍Oracle...
### Oracle常用函数集详解 #### 一、ASCII函数 **功能描述:** ASCII函数用于返回与指定字符相对应的十进制数值。 **语法格式:** ```sql ASCII('字符') ``` **示例:** ```sql SELECT ASCII('A') A, ASCII('a') ...
### Oracle常用函数详解 #### 一、概述 Oracle 数据库提供了丰富的内置函数,极大地提高了 SQL 语句在处理数据时的灵活性与效率。这些函数主要分为两大类:单行函数和多行函数(也称为聚合函数)。单行函数通常...
以下是从“Oracle常用函数.txt”文件中提炼出的关键知识点,旨在为初学者提供深入理解与实践的指导。 ### ASCII() 和 CHR() - **ASCII()** 函数用于返回一个字符的ASCII码值。例如,`ASCII('A')` 返回的是65,而 `...
ORACLE常用函数总结,与SQL SERVER对比,防止混淆,更容易记忆。
oracle常用函数oracle常用函数oracle常用函数oracle常用函数oracle常用函数oracle常用函数oracle常用函数
以下是对标题和描述中提到的Oracle常用函数的详细总结: 1. ASCII 函数:这个函数返回一个字符对应的ASCII码,即十进制数字。例如,`ASCII('A')`返回65,`ASCII(' ')`返回32(空格的ASCII码)。 2. CHR 函数:与...
sql,mysql,oracle常用的函数
hive和oracle常用函数对照,包含常用的函数分类 字符函数 数值函数 日期函数 聚合函数 转换函数 其他 增加的hive函数对比,只需要2个积分喔
Oracle数据库中的常用函数是数据库管理员和开发人员在处理数据时不可或缺的工具。这些函数极大地提高了数据处理的效率和灵活性。以下是一些常见的Oracle分析函数及其用法: 1. **开窗函数(Over)**: 开窗函数允许...
### Oracle常用函数与使用方法详解 #### 一、Oracle SQL函数概述 在Oracle数据库中,SQL函数被广泛用于处理各种数据类型,包括数值、字符、日期等,它们能够帮助我们更高效地进行数据检索和分析。本文将详细介绍...
"Oracle常用函数chm版"是一个集合了多种Oracle数据库常用函数的参考资源,主要包含以下几个方面: 1. **数值型函数**:这类函数主要用于处理整数、浮点数等数值类型的数据。例如,`ROUND`函数用于四舍五入,`TRUNC`...
3.CONCAT:连接两个字符串; SQL> select concat('010-','88888888')||'转23' 张三电话 from dual; 张三电话 ...SQL> select instr('oracle traning','ra',1,2) instring from dual; INSTRING ---------
本文将深入探讨"Oracle常用函数"以及"SQL*Plus基本命令"这两个关键领域,旨在帮助你提升在数据库操作中的效率。 一、Oracle常用函数 1. 长度函数`LENGTH` `LENGTH`函数用于计算字符串的字符数,不区分字符类型(如...
本篇文章主要探讨Oracle常用函数,特别是涉及字符串处理、日期处理以及数据处理的函数。 1. **字符串处理函数**: - `SUBSTR(string, start_position, length)`: 从指定的字符串`string`中提取子字符串,从`start_...
本文将基于"Oracle常用函数 CHM"这个资源,详细解析一些Oracle数据库中常见的函数及其应用,帮助你更好地理解和掌握Oracle SQL查询语言。 1. **字符串处理函数** - `UPPER()` 和 `LOWER()`:这两个函数用于将字符...
Oracle创建函数是通过PL/SQL自定义编写的,通过关键字function按照自己的需求把复杂的业务逻辑封装进PL/SQL函数中,函数提供一个返回值,返回给使用者。这样使用者就不需要去理解业务逻辑,把PL/SQL函数中的业务逻辑...