用SHELL的循环批量执行SQL语句
--ksh下的一个WHILE 循环的例子
integer i=1
while ((i<67))
do
pirnt $i
i=i+1
done
--ksh 下一个FOR循环的例子
for i in `cat listdate.txt`
do
echo "执行 $i "
done
--- date.pl 用于生成一个时间段文件
#!/usr/local/bin/perl
use DBI;
if($#ARGV<1)
{
die "USAGE:date.pl <startdate> <enddate> \n";
return(0);
}
$rundate1=$ARGV[0];
$rundate2=$ARGV[1];
$dbh=DBI->connect('dbi:Oracle:host=192.xx.xx.2;sid=ora7','report/system','')||
die('cann\'t connect to database');
$date=$dbh->prepare("select cal_date from calendar where cal_date between to_date(?,'yyyymmdd') and to_date(?,'yyyymmdd')");
$date->bind_param( 1, $rundate1);
$date->bind_param( 2, $rundate2);
$date->execute;
while (@row = $date->fetchrow_array)
{
printf("$row[0]\n");
}
$dbh->disconnect;
---实例 批处理执行一段时间 每天 要执行的程序
date.pl 20100101 20100307 > listdate.txt
for i in `cat listdate.txt`
do
echo "执行 $i "
sqlplus cust/cust @cust_get_jf_md2010.sql $i
done
相关文档:
一、SQL Server中数据行的存储方式
在SQL Server中存放数据的文件会以8KB的大小分页。每一页可以是数据、索引以及其他SQL Server数据库需要为其维护数据文件的数据类型。大多数页是数据页或索引页。页是SQL Server读、写数据文件的单元。每一页只包括一个对象的数据或索引信息,所以在每一个数据 ......
SQL版:
alter proc testguo
(
@cityid int,
@cityname nvarchar(100) output
)
as
select @cityname = city_name from BA_Hot_City where cityid = @cityid
select @cityname
go
declare @cityname nvarchar(100)
exec testguo 1,@cityname output
另一版:
ht ......
sql server 临时表的使用 以及给临时表插入主键列
--某时间段内某组服务器的消费排行
CREATE PROCEDURE biling_order_consume
@begin_date datetime,
@end_date datetime
AS
select identity(int,1,1) as ID,charge_credit into #tmp from crm_biling
where @begin_date <= convert(datetime,convert( ......
语法:
CREATE [索引类型] INDEX 索引名称
ON 表名(列名)
WITH FILLFACTOR = 填充因子值0~100
GO
/*实例*/
USE 库名
GO
IF EXISTS
(SELECT * from SYSINDEXES WHERE NAME='IX_TEST_TNAME')--检测是否已经存在IX_TEST_TNAME索引
DROP INDEX
TEST.IX_TEST_TNAME--如果存在则删除
--创建索引
CREATE NONCLUSTER ......