Uses of Function-Based Indexes (200)

本文介绍了如何通过创建函数索引来优化包含函数的WHERE子句的SQL语句执行效率。特别强调了使用UPPER和LOWER函数建立函数索引来实现大小写不敏感的搜索,并讨论了其在全球化支持排序索引中的应用。

Function-based indexes provide an efficient mechanism for evaluating statements that
contain functions in their WHERE clauses. The value of the expression is computed and
stored in the index. When it processes INSERT and UPDATE statements, however,
Oracle must still evaluate the function to process the statement.

Function-based indexes defined on UPPER(column_name) or LOWER(column_name) can facilitate
case-insensitive searches.

A function-based index can also be used for a globalization support sort index that
provides efficient linguistic collation in SQL statements.

使用函数索引
1. 如果一个 SQL 语句的 WHERE 子句中使用了函数,那么建立相应的函数索引是提高数据访问性能
2. 使用 UPPER(column_name) 或 LOWER(column_name) 函数建立函数索引需要注意大小敏感性

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-982469/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10599713/viewspace-982469/

A study was conducted, in which participants, between 18 and 99 years old, were asked to complete a task. Each participant received a score between 0 and 100. The scores that the participants achieved in the task were recorded, as well as their first names, last names, ages, genders, and amount of prior experience. Approximately 10,000 people participated in the study. Unfortunately, a few mistakes were made in recording the data: Some participants’ information was recorded in the database multiple times. Some participants did not specify their gender leaving it blank instead of as ‘Male’, ‘Female’, or ‘Other’. Some participants specified their prior experience on a scale of 1 to 10 instead of 1 to 5 as instructed. For some participants, their scores were corrupted and replaced with NaN. In this assignment, you will practice data cleaning. The input is a file named ‘input.csv’ (see reading materials), which will be read and saved as a table variable ‘T’. You will write a function called ‘clean_table’. This function will take the table variable ‘T’ as input and handle the following data cleaning tasks: Remove duplicate rows. Replace NaN values in the score column with the mean score of other participants. Replace any empty string in the gender column with ‘unspecified’. For participants who entered prior experience using a 1-to-10 scale instead of the required 1-to-5 scale, divide their experience by 2 and round it down using the floor function. Function function T2 = clean_table(table) % Remove duplicated rows. Assign the table to T2. You may refer to the warm-up exercise. % Your code here: % Find the indexes of scores with a value of ‘NaN’; Assign them to zero; Use the same way of the warm-up exercise to calculate the mean score; Assign the mean value to those with ‘NaN’. % Your code here: % You may use the fillmissing function. Here it is. You may explain it. T2 = fillmissing(T2, ‘constant’, ‘unspecified’, ‘DataVariables’, {‘Gender’}); % Access those with prior experience value >5 and floor them. You may use a similar way compared to the warm-up exercise. % Your code here: end code to call your function T = readtable(“input.csv”); clean_table(T);
09-10
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值