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<$len;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 两个文件按列合并,并且两文件的结合列中用逗号分隔。
相关文档:
将Excel文件数据库导入SQL Server的三种方案
//方案一: 通过OleDB方式获取Excel文件的数据,然后通过DataSet中转到SQL Server
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel files(*.xls)|*.xls";
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FileInfo ......
--基于时间SQL函数--
getdate() --返回当前系统日期和时间。
DateAdd --在向指定日期加上一段时间的基础上,返回新的 datetime 值。
DATEADD ( datepart , number, date )
--例:向当天的时间增加5天
select dateadd(dd,5,getdate())
datediff --返回跨两个指定日期的日期和时间边界数。]
---例如
& ......
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 ......
1.读出表中的字段名
ResultSet rs = test.selectSql("SELECT * from datainfo");
java.sql.ResultSetMetaData md=rs.getMetaData(); //读出数据库的字段名
int nColumn=md.getColumnCount(); //字段总数
for(int i=0;i<nColumn;i++)
& ......
方法一:
打开企业管理器->SQL SERVRE 组->(local)window NT ->属性
产品:有personal的是个人版的,有Enterprise的是企业版的
产品版本:8.00.2039(sp4);8.00.760(sp3)
方法二:
第一步:在查询分析器
select @@version
print @@version
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005 ......