ocp-047-91

91. View the Exhibit and examine the data in the LOCATIONS table. 
Evaluate the following SQL statement: 
SELECT street_address 
FROM locations WHERE REGEXP_INSTR(street_address,'[^[:alpha:]]') = 1; 
Which statement is true regarding the output of this SQL statement? 
A. It would display all the street addresses that do not have a substring 
'alpha'. 
B. It would display all the street addresses where the first character is 
a special character. 
C. It would display all the street addresses where the first character is 
a letter of the alphabet. 
D. It would display all the street addresses where the first character is 

not a letter of the alphabet. 

Answer: D 
REGEXP_INSTR 有6个参数: 
第一个是输入的字符串   第二个是正则表达式 
第三个是标识从第几个字符开始正则表达式匹配。(默认为1) 

第四个是标识第几个匹配组。(默认为1) 
第五个是指定返回值的类型,如果该参数为0,则返回值为匹配位置的第一个字符,如果该值为
非0则返回匹配值的最后一个位置。 
第六个是是取值范围: 
i:大小写不敏感; c:大小写敏感; n:点号 . 不匹配换行符号; 
m:多行模式;     x:扩展模式,忽略正则表达式中的空白字符。 
正则表达式规则:    [^. . .]    --- A “not equals” bracket expression 
                 |      --- Logical OR. 
                   .    --- Match any character in the database character set. 
                   $    --- End of line anchor 
                   ^   --- Beginning of line anchor. 
+      ---Match one or more occurrences of the preceding subexpression. 
SQL> select REGEXP_I NSTR('1234aa','[:alpha:]') from dual; 第一个字母的位置 
REGEXP_INSTR('1234AA','[:ALPHA:]') 
---------------------------------- 
                                 5 
 

 
SQL> select REGEXP_INSTR('1234aa','[^[:alpha:]]') from dual; 第一个非字母的位置 
REGEXP_INSTR('1234AA','[^[:ALPHA:]]') 
------------------------------------- 
                                    1 
做题的是注意细节,有[^表示非的意思 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值