本文共 1432 字,大约阅读时间需要 4 分钟。
shell中使用SQL实现查询
先把文本进行格式处理,然后以空格为分隔符,取第二个空格后的字串,排序,去重,再降序排列,取前5个
arr=($(cat 0100055F_Detail.txt|sed -e '/:/d'|awk -F ' ' '{print$2}'|sort|uniq -c|sort -nr|head -5|awk '{print $2}'))
len=${#arr[@]} 获取数组长度
for((i=0;i
do
echo ${arr[$i]}
mysql -uroot -p123456 -e "select location from IPLocation.IPLocation where IP_address='${arr[$i]}'"|sed 's/\t/,/g' >> table.csv 执行查询:-u后是用户名,-p后事密码,-e表示执行;
done
cat table.csv|sed -e '/location/d'>table1.csv
paste -d ',' result.csv table1.csv >last.csv 两个文件按列合并,并且两文件的结合列中用逗号分隔。
相关文档:
--基于时间SQL函数--
getdate() --返回当前系统日期和时间。
DateAdd --在向指定日期加上一段时间的基础上,返回新的 datetime 值。
DATEADD ( datepart , number, date )
--例:向当天的时间增加5天
select dateadd(dd,5,getdate())
datediff --返回跨两个指定日期的日期和时间边界数。]
---例如
& ......
http://hi.baidu.com/dumao/blog/item/1cafa71e5886d019413417e4.html
1.全文索引概述
对 Microsoft® SQL Server™ 2000 数据的全文支持涉及两个功能:对字符数据发出查询的能力和创建及维护基础索引以简化这些查询的能力。
全文索引在许多地方与普通的 SQL 索引不同。
普通 SQL 索引全文索引
存储时受 ......
Introducing Oracle Database 11g
List the features of Oracle Database 11g
Discuss the basic design, theoretical and physical aspects of a relational database
Categorize the different types of SQL statements
Describe the data set used by the course
Log onto the database using the SQL Develope ......
排名函数是SQL Server2005新加的功能。在SQL Server2005中有如下四个排名函数:
1. row_number 自动生成行号,序号由order by 字段决定
2. rank over Filed, 由rank over的字段决定,名次不连续,如有3个并列第一名,则后续名次直接从4开始
3. dense_rank,和rank相似,只是名次连续,如有3个并列第一名� ......
转载地址:http://ixodl.baihongyu.com/