易截截图软件、单文件、免安装、纯绿色、仅160KB

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 常用查询大全

oracle常用经典SQL查询
常用SQL查询:
 
1、查看表空间的名称及大小
 
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
 
2、查看表空间物理文件的名称 ......

Oracle日期函数集锦

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日期函数集锦(二)

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 ......

Oracle日期函数集锦(三)

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号