偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

SQL Server 2005大批量數(shù)據(jù)的操作與實例演示

數(shù)據(jù)庫 SQL Server
以下的文章主要介紹的是SQL Server 2005大批量數(shù)據(jù)的實際操作以及其使用的實例描述,下面就是文章的主要內(nèi)容的詳細介紹。

我們今天主要向大家講述的是SQL Server 2005大批量數(shù)據(jù)的實際操作以及其使用的實例描述,以下是文章的具體介紹,望你瀏覽完以下的內(nèi)容會有所收獲。我們首先是以問題提出的方式來對其進行講述:

 

在SQL Server 2005數(shù)據(jù)庫中建立兩個類型相同的數(shù)據(jù)表,如下

 

  1. create table test1  
  2. (  
  3. iId int identity(1,1) not null,  
  4. vTest1Code varchar(30) not null,  
  5. vName varchar(30) not null,  
  6. dDate datetime,  
  7. primary key(iId)  
  8. )   
  9. create table test2  
  10. (  
  11. Id int identity(1,1) not null,  
  12. Code varchar(30) not null,  
  13. Name varchar(30) not null,  
  14. date datetime,  
  15. primary key(Id)  
  16. )  

 

兩表所占用的系統(tǒng)空間

 

  1. exec sp_spaceused 'test1' exec sp_spaceused 'test2'   
  2. Name Rows Reserved Data Index_size unused   
  3. Test1 0 0KB 0KB 0KB 0KB   
  4. Test2 0 0KB 0KB 0KB 0KB  

由上圖得知兩表所占用的系統(tǒng)空間一致。

執(zhí)行數(shù)據(jù)插入操作

 

--測試TEST1

 

  1. declare @startTime datetime  
  2. set @startTime=getdate()  
  3. declare @i int  
  4. set @i=1 
  5. while @i<100 
  6. begin  
  7. insert into test1(vTest1Code,vName) values('vCode'+CAST(@i as varchar(10)),'vName'+CAST(@i as varchar(10)))  
  8. set @i=@i+1  
  9. end 

select [語句執(zhí)行花費時間(毫秒)]=datediff(ms,@startTime,getdate())

go

 

--測試TEST2

 

  1. declare @startTime datetime  
  2. set @startTime=getdate()  
  3. declare @i int  
  4. set @i=1 
  5. while @i<100 
  6. begin  
  7. insert into test2(Code,Name) values('vCode'+CAST(@i as varchar(10)),'vName'+CAST(@i as varchar(10)))  
  8. set @i=@i+1  
  9. end 

select [語句執(zhí)行花費時間(毫秒)]=datediff(ms,@startTime,getdate())

go

 

插入耗時情況

test1語句執(zhí)行花費時間(毫秒) test2語句執(zhí)行花費時間(毫秒)

 

  1. 100條 30 30   
  2. 1000條 250 250   
  3. 10000條 2623 2516   
  4. 100000條 26453 26560   
  5. 1000000條 275110 282796  

最后兩表所占用的系統(tǒng)空間

 

  1. exec sp_spaceused 'test1' exec sp_spaceused 'test2'   
  2. Name Rows Reserved Data Index_size unused   
  3. Test1 1000098 48520KB 48272KB 192KB 56KB   
  4. Test2 1000098 48520KB 48272KB 192KB 56KB  

問題現(xiàn)象描述:

<!--[if !supportLists]-->1、 <!--[endif]-->在相同數(shù)據(jù)類型、長度,及約束、索引的情況下,執(zhí)行千條及千條以內(nèi)的數(shù)據(jù)插入操作時,字段長度、系統(tǒng)保留字對SQL語句的執(zhí)行速度沒有影響或者影響很??;執(zhí)行上萬條數(shù)據(jù)插入操作時,字段長度對SQL語句的執(zhí)行速度影響很??;執(zhí)行十萬條以上的數(shù)據(jù)操作時,系統(tǒng)保留字對SQL語句的執(zhí)行速度影響明顯。

 

<!--[if !supportLists]-->2、 <!--[endif]-->數(shù)據(jù)字段長度、系統(tǒng)保留字對系統(tǒng)占用的空間沒有任何影響。

 

<!--[if !supportLists]-->3、 <!--[endif]-->在SQL Server 2005大批量數(shù)據(jù)操作時,數(shù)據(jù)類型、長度,甚至數(shù)據(jù)字段是否為系統(tǒng)保留字,對SQL語句的執(zhí)性效率都有影響。

 

問題總結(jié):

 

<!--[if !supportLists]-->1、 <!--[endif]-->SQL語句在執(zhí)行時,將首先對相關(guān)數(shù)據(jù)表進行連接,然后進行過濾、分組、選擇字段、DISTINCT、ORDER BY等操作。由此,我們在進行數(shù)據(jù)查詢時,應(yīng)盡量避免“*”連接,應(yīng)考慮過濾的先后順序。

 

<!--[if !supportLists]-->2、 <!--[endif]-->謹慎使用游標、觸發(fā)器、索引。

 

<!--[if !supportLists]-->3、 <!--[endif]-->盡量避免使用系統(tǒng)保留字,考慮在SQL語句中區(qū)分數(shù)據(jù)字段的大小寫,即SQL語句中的字段名的形式應(yīng)和數(shù)據(jù)表中的字段名的形式一致。

 

以上的相關(guān)內(nèi)容就是對SQL Server 2005大批量數(shù)據(jù)操作使用實例的介紹,望你能有所收獲。

【編輯推薦】

  1. 正確維護Sql Server表索引的2個步驟
  2. SQL Server數(shù)據(jù)轉(zhuǎn)換服務(wù)的妙招之一
  3. SQL Server數(shù)據(jù)庫的妙招用法
  4. SQL Server數(shù)據(jù)轉(zhuǎn)換服務(wù)利用與導入式格式的描述
  5. 正確維護Sql Server表索引的2個步驟

 

責任編輯:佚名 來源: Linux人社區(qū)
相關(guān)推薦

2010-07-16 14:17:18

SQL Server

2010-07-20 17:47:12

2010-09-09 16:10:57

sql server2循環(huán)

2020-11-02 09:53:13

Hive數(shù)據(jù)算法

2011-07-06 13:09:11

SQL Server

2010-06-28 11:00:46

SQL Server

2010-07-09 14:30:56

SQL Server

2018-08-09 08:59:56

數(shù)據(jù)庫MySQL性能優(yōu)化

2010-07-21 09:50:12

SQL Server子

2010-07-05 15:04:36

SQL Server刪

2010-07-14 10:03:40

SQL Server

2011-08-22 09:55:30

SQL Server 排序

2010-11-02 10:52:15

批量清理文件

2010-04-26 14:52:05

Oracle大批量數(shù)據(jù)

2010-09-03 10:40:30

SQL刪除

2020-12-18 10:40:00

ExcelJava代碼

2021-06-28 10:25:47

MySQL數(shù)據(jù)庫重復數(shù)據(jù)

2010-07-16 17:03:35

SQL Server

2021-09-14 13:15:43

MySQL數(shù)據(jù)庫腳本

2010-07-22 09:33:45

SQL Server全
點贊
收藏

51CTO技術(shù)棧公眾號