insertintotablename与Select*intotablename比较

insertintotablename与Select*intotablename比较,第1张

insertintotablename与Select*intotablename比较,第2张

当插入到tablename时,表tablename必须存在
当selecting * into tablename时,表不能存在。

当数据库的恢复模式简单时,Select * into tablename更快,因为当数据库的恢复模式简单时,select * into tablename不会生成大量日志。


-测试:
-前提条件是数据库的故障回复模型很简单。

-1.使用select into生成包含大量数据的表。您可以在语句运行之前检查您的ldf文件(日志)
-然后在语句运行之后检查它。对数增长非常小。并且建表速度更快
如果存在(select * from dbo.sysobjects其中id = object _ id(N @ #[TB _ pwd 3]@ #)and object property(id,N @ # I supertable @ #)= 1)
drop table[TB _ pwd 3]
Go
-生成临时表
-Select Top 256 seq _ no = identity(int,0,1)into # t from sys columns
-生成密码3

删除表#t

——你要分别测试这两种情况。测试第二种情况的时候,你得保证你的磁盘有足够的空,而且磁盘格式必须是ntfs格式。


-2。使用insert into生成包含大量数据的表。您可以在语句运行之前检查您的ldf文件(日志)
-然后在语句运行之后检查它。日志增长很快,但建表速度也很慢。如果存在,则写入日志
( Select * from dbo . sysobjects,其中id = object _ id (n @ # [TB _ pwd3] @ #)和object property (id,N @ # I supertable @ #)= 1)
drop table[TB _ pwd 3]
go
create table TB _ pwd 3(
pwd char(3)
)
go[Select 256 seq _ no = identity(int,0,1)

删除表#t

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » insertintotablename与Select*intotablename比较

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情