一、原题
View the Exhibit and examine the structure of the CUSTOMERS table.

In the CUSTOMERS table, the CUST_LAST_NAME column contains the values 'Anderson' and 'Ausson'.
You issue the following query:
SQL> SELECT LOWER(REPLACE(TRIM('son' FROM cust_last_name),'An','O'))
FROM CUSTOMERS
WHERE LOWER(cust_last_name) LIKE 'a%n';
What would be the outcome?
A. 'Oder' and 'Aus'.
B. an error because the TRIM function specified is not valid.
C. an error because the LOWER function specified is not valid.
D. an error because the REPLACE function specified is not valid.
答案:B
二、题目翻译In the CUSTOMERS table, the CUST_LAST_NAME column contains the values 'Anderson' and 'Ausson'.
You issue the following query:
SQL> SELECT LOWER(REPLACE(TRIM('son' FROM cust_last_name),'An','O'))
FROM CUSTOMERS
WHERE LOWER(cust_last_name) LIKE 'a%n';
What would be the outcome?
A. 'Oder' and 'Aus'.
B. an error because the TRIM function specified is not valid.
C. an error because the LOWER function specified is not valid.
D. an error because the REPLACE function specified is not valid.
答案:B
看下面CUSTOMERS表的结构
表中CUST_LAST_NAME列包含'Anderson' and 'Ausson'值.
执行下面的SQL查询语句
执行结果是什么?
A.'Oder' and 'Aus.
B.报错,因为TRIM函数无效。
C.报错,因为LOWER函数无效。
D.报错,因为REPLACE函数无效。
三、题目解析表中CUST_LAST_NAME列包含'Anderson' and 'Ausson'值.
执行下面的SQL查询语句
执行结果是什么?
A.'Oder' and 'Aus.
B.报错,因为TRIM函数无效。
C.报错,因为LOWER函数无效。
D.报错,因为REPLACE函数无效。
因为TRIM('son' FROM cust_last_name)第一个参数不能是多个字符,只能是一个,这里,有'son'三个字符,
SQL> select TRIM('son' FROM 'Anderson') from dual;
select TRIM('son' FROM 'Anderson') from dual
*
ERROR at line 1:
ORA-30001: trim set should have only one character
SQL> select TRIM('son' FROM 'Anderson') from dual;
select TRIM('son' FROM 'Anderson') from dual
*
ERROR at line 1:
ORA-30001: trim set should have only one character
本文深入探讨了SQL查询中常见错误的成因,并提供了有效的解决策略,特别关注了TRIM函数的应用限制,通过实例解释了如何正确使用SQL函数以避免错误。
1144

被折叠的 条评论
为什么被折叠?



