当前位置:首页 » 编程语言 » sql语句一万行
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

sql语句一万行

发布时间: 2022-07-20 06:48:18

1. 如果用sql查询10000条以上数据用什么方法查询

10000条,真的不算多.1千万条的我都见过,那个查询一般要跑2-3个小时.
直接用select就可以.如果嫌慢就加个索引.

2. sql文1次性添加10000条数据

declare@countint=1
while(@count<=10000)
begin
insertintoseinouvalues(@count,'','')
set@count=@count+1
end

另外,如果表定义的时候id已经自增长了,把除了id以外的字段都列出来

declare@countint=1
while(@count<=10000)
begin
insertintoseinou(column1,column2)values('','')
set@count=@count+1
end

3. sql写语句如何循环执行10000次

调用循环执行,例如:

declare@nint
set@n=0
begin
while@n<10000
set@n=@n+1
--这里运行您要执行的1万次操作
--例如您提问中的那些动作查询

end

4. 在线求怎么在数据库造1万条数据的SQL语句!

oracle:
create table myTestTable as
select rownum as id,
to_char(sysdate + rownum/24/3600, 'yyyy-mm-dd hh24:mi:ss') as inc_datetime,
trunc(dbms_random.value(0, 100)) as random_id,
dbms_random.string('x', 20) random_string
from al
connect by level <= 100000;

SqlServer:
SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
scsb.DataSource = @"127.0.0.1\SQLEXPRESS";
scsb.InitialCatalog = "MyMoreRows";//数据库名称
scsb.IntegratedSecurity = true;

int numOfTestRecords = 30000;//要创建的行数
string insertstr = "INSERT INTO LoadTable(teststr1, teststr2, teststr3)" +//LoadTable表名
"VALUES(@teststr1, @teststr2, @teststr3)";

SqlParameter teststr1param = new SqlParameter("@teststr1", SqlDbType.NVarChar, 50);
SqlParameter teststr2param = new SqlParameter("@teststr2", SqlDbType.NVarChar, 50);
SqlParameter teststr3param = new SqlParameter("@teststr3", SqlDbType.NVarChar, 50);

using (SqlConnection conn = new SqlConnection(scsb.ToString()))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = insertstr;
comm.Parameters.Add(teststr1param);
comm.Parameters.Add(teststr2param);
comm.Parameters.Add(teststr3param);

SqlTransaction tran = conn.BeginTransaction("testtran");
comm.Transaction = tran;
try
{
for (int i = 0; i < numOfTestRecords; i++)
{
teststr1param.Value = "Col1Test-" + i;
teststr2param.Value = "Col2Test-" + i;
teststr3param.Value = "Col3Test-" + i;

comm.ExecuteNonQuery();
textBox1.AppendText(">" + i + "<");
}
tran.Commit();
}
catch (Exception ex)
{
tran.Rollback();
}

}

5. 怎样用一条sql语句向数据库中插入10000条记录

只能用循环了,以下是php语法
for($i=0;$i<10001;$i++){
INSERT INTO TABLE();//这里式sql语句
}

6. SQL语句 如何让数据10000查询出来显示为1万或者一万

虽然每条语句提取出来的都是25万条数据,各种情况的差异却是巨大的,特别是将运行前我们可以把SQL SERVER的statistics I/O状态打开。 (1)select title,

7. sql语句查询上万条数据。

用NOT IN 是很慢的一种查询方式。
试试用Join。

select a.*, 'N' as chk from pay a
where a.txn_dt = '20090110'
and txn_sta_cd = '6'
union
select * from (
select b.*, isnull(c.txn_user_id,'N') as chk
from pay b left outer join pay c
on b.txn_user_id = c.txn_user_id
and b.txn_dt = c.txn_dt
and b.txn_sta_cd = '7'
and c.txn_sta_cd = '6'
where b.txn_dt = '20090110' ) d
where d.chk = 'N'
=========================================
如果不行, 试试下面的

select a.*, 'N' as chk
from pay a
where a.txn_dt = '20090110'
and a.txn_sta_cd = '6'
union
select * from (
select b.*, isnull(c.txn_user_id,'N') as chk
from
(select * from pay
where txn_dt='20090110'
and txn_sta_cd = '7') b left outer join
(select * from pay
where txn_dt='20090110'
and txn_sta_cd = '7') c
on b.txn_user_id = c.txn_user_id) d
where d.chk = 'N'

强烈要求补分~~~!!!!!!!