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,也就说既有字母也有数字,那么就没问题了。
相关文档:
oracle表空间操作详解
1
2
3作者: 来源: 更新日期:2006-01-04
5
6
7建立表空间
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
SQL中的单记录函数
1.ASCII
返回与指定的字符对应的十进制数;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;
A A ZERO ......
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.上月末天:
select to_char(add_months(last_day(sysdate),-1),'yyyy-MM-dd') LastDay from dual;
2.上月今天
SQL> select to_char(add_months(sysdate,-1),'yyyy-MM-dd') PreToday from dual;
3.上月首天
SQL> select to_char(add_months(last_day(sysdate ......