架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6786|回复: 0

[资料] sql最近几天的笔记

[复制链接]
发表于 2015-2-9 16:09:55 | 显示全部楼层 |阅读模式
select * from sgk where id =1;
exec sp_spaceused sgk;

--JIU:423771079  156005274

--rows
--428700186  

select top 10 * from sgk order by id desc
--mohuchaxun
select * from sgk where name1 like '%123%'
select * from sgk where email like '%123%'
--jingquechaxun
select * from sgk where name1 ='123'
--lianhechax
select * from sgk where name1 like '%123%' or email like '%123%'

select * from sgk where name1 = '123' or email = '123@qq.com'

--开启SQL SERVER的AWE,并设置最大内存为8G
sp_configure "show advanced options", 1
RECONFIGURE WITH OVERRIDE
GO
sp_configure "awe enabled", 1
RECONFIGURE WITH OVERRIDE
GO
sp_configure "max server memory", 8120
RECONFIGURE WITH OVERRIDE
GO
RECONFIGURE
GO



select  top 1000000 *  into testtable from  sgk


sp_attach_single_file_db @dbname=  'QunInfo1' ,
@physname= 'E:\BaiduYunDownload\QQ数据库\QQ数据库\QunData\QunInfo1_Data.MDF'

sp_attach_single_file_db @dbname=  'QQ_GroupData1' ,
@physname= 'E:\BaiduYunDownload\QQ数据库\QQ数据库\QunData\GroupData1_Data.MDF'


insert into QQ_GroupData.dbo.Group101
select * from Group1


insert  Group1
select * from(
select QQNum,Nick,Age,Gender,Auth,QunNum from Group2
union
select QQNum,Nick,Age,Gender,Auth,QunNum from Group3
union
select QQNum,Nick,Age,Gender,Auth,QunNum from Group4
)t



DECLARE @i int  
Set @i = 2
--开始循环插入数据
WHILE @i < 3 and @i>1
BEGIN   
insert  Group1
select * from(
select QQNum,Nick,Age,Gender,Auth,QunNum from Group+@i
)t
Set @i =@i +1
END   
select count(*) from Group1
--760440
truncate table group1

select * from Group100

select * from QunList2

select 'insert into group1 select * from '+DB_NAME()+'dbo.'+o.name+';' from sys.objects o where o.name like '%group%';
select 'insert into group1 select * from '+o.name+';' from sys.objects o where o.name like '%group%' and o.type='U';
select 'drop table '+o.name+';' from sys.objects o where o.name like '%group%' and o.type='U';



select * from Group1 where QQNum='123'
DBCC FREEPROCCACHE
DBCC ShrinkDatabase(QQ_GroupData1)






上一篇:普通SQL语句可以用exec执行
下一篇:MSSQL删除大量的表记录后,数据库容量没有减小
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-4-30 19:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表