SQL函数(二)
来源:互联网 发布:mac口红免税店价格 编辑:程序博客网 时间:2024/05/17 04:44
SQL> select 2312321.5435345 fromdual;
2312321.5435345
---------------
SQL> select to_char(2312321.5435345,'S0999999.9999') from dual;
TO_CHAR(23123
-------------
+2312321.5435
SQL> select to_char(2312321.5435345,'S0000999999.9999') from dual;
TO_CHAR(2312321.
----------------
+0002312321.5435
SQL> select to_char(2312321.5435945,'S0000999999.9999') from dual;
TO_CHAR(2312321.
----------------
+0002312321.5436
SQL> select to_char(2312321.5435945) fromdual;
TO_CHAR(2312321
---------------
2312321.5435945
SQL> select to_char(2312321.5435945) + 1 from dual;
TO_CHAR(2312321.5435945)+1
--------------------------
SQL> select 2312321.5435945 + 1 from dual;
2312321.5435945+1
-----------------
SQL> select to_char(2312321.5435945) || 1 fromdual;
TO_CHAR(2312321.
----------------
2312321.54359451
SQL> select '1232' fromdual;
'123
----
1232
SQL> select '1232' + 1 from dual;
----------
SQL> select '1232' || 1 from dual;
'1232
-----
12321
SQL> select to_number('1232') || 1 fromdual;
TO_NU
-----
12321
SQL> select to_number('1232') + 1 fromdual;
TO_NUMBER('1232')+1
-------------------
SQL> select * fromemployees
EMPLOYEE_ID MANAGER_ID FIRST_NAME LAST_NAME TITLE SALARY
----------- ---------- ---------- ------------------------------ ----------
SQL> select * fromcustomers
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers wherelast_name like 'Bl%'
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers wherelast_name like 'Bl%';
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'Bl');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'l');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers wherelast_name like '_l%';
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers wherelast_name like '%l%';
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'B..e')
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * fromcustomers
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'B[lmn][abcuvw][cde]')
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'B[lmn][abcuvw][cde]$')
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, '[A-Z][a-z]')
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, '[A-Za-z][a-z]')
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, '[A-Za-z0-9][a-z]');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * fromcustomers;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'l(ue|ack)');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, '[l](ue|ack)');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, '^[l](ue|ack)');
未选定行
SQL> select * from customers whereregexp_like(last_name, '^l(ue|ack)');
未选定行
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{4}')
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{2}');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{2}$');
未选定行
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{3}$');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{4}$');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{2}$');
未选定行
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{2}');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{2}$');
未选定行
SQL> select * From customers whereregexp_like(last_name, '^B[a-z]{2}$');
未选定行
SQL> select * From customers whereregexp_like(last_name, '^B[a-z]{2}');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * From customers whereregexp_like(last_name, '^[a-z]{2}');
未选定行
SQL> select * From customers whereregexp_like(last_name, '^B[a-z]{2}$');
未选定行
SQL> select * From customers whereregexp_like(last_name, '^B[a-z]{2, 5}$');
未选定行
SQL> select * From customers whereregexp_like(last_name, '^B[a-z]{2, 5}');
未选定行
SQL> select * From customers whereregexp_like(last_name, 'B[a-z]{2, 5}');
未选定行
SQL> select * fromcustomers;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'B[a-z]{4}');
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ------------------------ ------------
SQL> select * from customers whereregexp_like(last_name, 'B[a-z]{4, 5}');
未选定行
SQL> select * from customers whereregexp_like(last_name, 'B[a-z]{2, 5}');
未选定行
SQL> select * from customers whereregexp_like(last_name, 'B[a-z]{2, 4}');
未选定行
SQL> select * from customers whereregexp_like(last_name, 'B[a-z]{4, }');
未选定行
SQL> select * from customers whereregexp_like(last_name, 'B[a-z]{2, }');
未选定行
SQL> select * from customers whereregexp_like(last_name, '[a-z]{2, }');
未选定行
SQL> exit
(9)如果查找要求是last_name中包含以’B’开头,紧接着的字符不是l,后续字符不限的字符串。可在[]中使
用^,中括号[]中的^ 表示否的含义:
【示例】SELECT * FROM customers WHEREREGEXP_LIKE(last_name,'B[^l]')
如果模式字符串是‘B[^lmn]’,则表示B后跟的字符不能是l,m,n三者之一。
(10)如果要求所查找的字符串中含有空白字符,可使用\s,\s符号匹配所有的空白字符,包括Tab字符。
【示例】SELECT * FROM customers WHEREREGEXP_LIKE(last_name,'[A-Za-z]+\s+[A-Za-z]+')
(11)对于[A-Za-z],可使用[[:alpha:]]替换,效果相同。
查找last_name由四个字符组成的用户信息:
【示例】SELECT * FROM customers WHEREREGEXP_LIKE(last_name,'^[[:alpha:]]{4}$')
其它的同义符如下:
[[:digit:]] ==[0-9]
[[:alphanum:]] ==[0-9a-zA-Z]
[[:lower:]] == [a-z]
[[:upper:]] == [A-Z]
[[:blank:]] == \s
\d ==[0-9]
\D == [^0-9]
\w == 字母数字下划线
\W == 非字母数字下划线
0 0
- SQL函数(二)
- Oracle SQL 内置函数大全 (二)
- Transact-SQL 程序设计(二) --------自定义函数
- Oracle sql函数精解(二)
- SQL Server自定义函数(二)
- oracle中的sql函数(二)
- oracle笔记(二)---SQL函数和SQL查询
- Oralce SQL语言常用函数(二)数字函数
- SQL SERVLER 系统函数(二)字符串函数
- pl/sql开发中的部分函数(二)
- SQL Server 2000基础教程——字符串函数(二)
- T-SQL(二)自定义函数的控制流语句
- Hive SQL操作与函数自定义(二)
- PL-SQL 编程(二)游标、存储过程、函数
- Oracle SQL 内置函数大全二
- SQL常用函数之二 QuoteName()
- PL/SQL练习题二(常用函数)
- 二十二、oracle pl/sql分类二 函数
- java-Transient关键字、Volatile关键字介绍和序列化、反序列化机制、单例类序列化
- SQL 多表联合查询
- vector和list的一些基本用法
- SQL函数(-)
- HDU 5011(博弈)
- SQL函数(二)
- java 线程synchronized 线程同步
- Java synchronized 关于…
- SQL 登陆
- Android网络编程之XML解析
- SQL时间查询和子查询
- SQL子查询
- 数字在排序数组中出现的次数
- IQKeyboardManager