ORACLE中搜索字母数字混合的字符串
SQL> with tt as
2 (
3 select 'haha' string from dual union
4 select '123' from dual union
5 select 'haha12' from dual union
6 select 'haha[]' from dual union
7 select '12@@' from dual union
8 select 'ah@!123' from dual
9 )
10 select string
11 from
12 (
13 select string,translate(
14 string,'abcdefghijklmnopqrstuvwxyz0987654321',
15 rpad('#',26,'#')||rpad('*',10,'*')
16 )
17 translated from tt
18 )
19 where instr(translated,'#') > 0
20 and instr(translated,'*') > 0;
STRING
-------
ah@!123
haha12
其实就是通过translate函数把所有字母和数字变换成两种统一的字符,上例中是把字母变为#,数字变为*,接着再外层select的where子句中对转换后的字符串进行判断,如果两者都大于0,也就说既有字母也有数字,那么就没问题了。
相关文档:
SQL中的单记录函数
1.ASCII
返回与指定的字符对应的十进制数;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;
A A ZERO ......
1.建表,插入数据
create table dept(deptno number,deptname varchar2(20),mgrno number);
insert into dept values(1,'总公司',null);
insert into dept values(2,'浙江分公司',1);
insert into dept values(3,'杭州分公司',2);
insert into dept values(4,'湖北分公司',1);
insert into dept values(5,'武汉分公司 ......
Oracle 10g 默认安装带来的用户名/密码
Username
Password
Description
See Also
CTXSYS
CTXSYS
The Oracle Text account
Oracle Text Reference
DBSNMP
DBSNMP
The account used by the Management Agent component of Oracle Enterprise Manager to monitor and manage the database
Oracle Enter ......
Oracle日期函数集锦(一)
一、 常用日期数据格式
1.Y或YY或YYY 年的最后一位,两位或三位
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07
SQL> Select to_ch ......
Oracle日期函数集锦(二)
二、常用时间函数
1.trunc(sysdate,'Q') 本季度第一天
SQL> select trunc(sysdate,'Q') from dual;
TRUNC(SYSDATE,'Q')
------------------
2007-4-1
2.trunc(sysdate,'D') 本周的第一天(周日)
SQL> select trunc(sysdate,'D')from dual;
TRUNC(SYSDATE,'D')
------------------
2 ......