ÈçºÎ²éѯSQL Server±¸·Ý»¹ÔÀúÊ·¼Ç¼
SQL ServerÔÚmsdbÊý¾ÝÖÐά»¤ÁËһϵÁÐ±í£¬ÓÃÀ´´æ´¢Ö´ÐÐËùÓб¸·ÝºÍ»¹ÔµÄϸ½ÚÐÅÏ¢¡£¼´Ê¹ÄãÕýÔÚʹÓõÚÈý·½µÄ±¸·ÝÓ¦ÓóÌÐò£¬Ö»ÒªÕâ¸öÓ¦ÓóÌÐòʹÓÃSQL ServerµÄÐéÄâÉ豸½Ó¿Ú(Virtual Device Interface---VDI)À´Ö´Ðб¸·ÝºÍ»¹ÔÖ´ÐУ¬ÄÇôִÐÐϸ½ÚÒÀÈ»±»´æ´¢ÔÚÕâһϵÁбíÖС£
´æ´¢Ï¸½ÚµÄ±í°üÀ¨£º
backupset
backupfile
backupfilegroup (SQL Server 2005 upwards)
backupmediaset
backupmediafamily
restorehistory
restorefile
restorefilegroup
logmarkhistory
suspect_pages (SQL Server 2005 upwards)
Äã¿ÉÒÔÔÚBooks OnlineÀïÃæÕÒµ½ÉÏÃæÕâЩ±íµÄ¾ßÌå˵Ã÷¡£
ÏÂÃæÕâ¸ö½Å±¾¿ÉÒÔ°ïÄãÕÒ³öÿ¸öÊý¾Ý¿â½üÆڵı¸·ÝÐÅÏ¢£º
SELECT b.name, a.type, MAX(a.backup_finish_date) lastbackup
from msdb..backupset a
INNER JOIN master..sysdatabases b ON a.database_name COLLATE DATABASE_DEFAULT = b.name COLLATE DATABASE_DEFAULT
GROUP BY b.name, a.type
ORDER BY b.name, a.type
Ö¸¶¨Êý¾Ý¿â×îºó20ÌõÊÂÎñÈÕÖ¾±¸·ÝÐÅÏ¢£º
SELECT TOP 20 b.physical_device_name, a.backup_start_date, a.first_lsn, a.user_name from msdb..backupset a
INNER JOIN msdb..backupmediafamily b ON a.media_set_id = b.media_set_id
WHERE a.type = 'L'
ORDER BY a.backup_finish_date DESC
Ö¸¶¨Ê±¼ä¶ÎµÄÊÂÎñÈÕÖ¾±¸·ÝÐÅÏ¢£º
SELECT b.physical_device_name, a.backup_set_id, b.family_sequence_number, a.position, a.backup_start_date, a.backup_finish_date
from msdb..backupset a
INNER JOIN msdb..backupmediafamily b ON a.media_set_id = b.media_set_id
WHERE a.database_name = 'AdventureWorks'
AND a.type = 'L'
AND a.backup_start_date > '10-Jan-2007'
AND a.backup_finish_date < '16-Jan-2009 3:30'
ORDER BY a.backup_start_date, b.family_sequence_number
ɾ³ý±¸·ÝÈÕÖ¾µÄÁ½¸ö´æ´¢¹ý³Ì£º
EXEC msdb..sp_delete_backuphistory '1-Jan-2005'
EXEC msdb..sp_delete_database_backuphistory 'AdventureWorks'
±¾ÎÄ·Òë×Ôsqlbackuprestore£¬¸ü¶à¾«²ÊÄÚÈÝÇëä¯ÀÀhttp://www.sqlbackuprestore.com
Ïà¹ØÎĵµ£º
--´´½¨Ð´ÎļþµÄ´æ´¢¹ý³Ì
ALTER proc [dbo].[p_movefile]
@filename varchar(1000),--Òª²Ù×÷µÄÎı¾ÎļþÃû
@text varchar(8000), --ҪдÈëµÄÄÚÈÝ
@obj int
as
begin
declare @err int,
@src varchar(255),
&n ......
Çë½Ì¸ßÊÖÒ»¸öÎÊÌ⣬ÎÊÌâÃèÊöÈçÏ£º
A±íÊǸ÷¸öµ¥Î»µÄÃû³Æ±í ×Ö¶ÎΪ org_id ºÍ org_name
B±íÊÇÕâЩµ¥Î»µÄµç»°ºÅÂë±í ×Ö¶ÎΪ org_idºÍ tel
A±í B±í¹ØÁª·½Ê½ÎªA.ORG_ID=B.ORG_ID
org_idÊǸ÷¸öµ¥Î»µÄ´úÂë
org_nameÊǸ÷¸öµ¥Î»µÄÃû³Æ
telÊǸ÷¸öµ¥Î»µÄµç»°ºÅÂë
±¾ÈËÏÖÔÚÏëÕë¶Ôÿ¸öµ¥Î»£¨Ã¿Ìõorg_id£©È¡Æä10¸öºÅÂë
Ç ......
1¡¢INSTR4(string1,string2[,a][,b]) ·µ»Østring1Öаüº¬string2µÄλÖÃaºÍbÊÇÒÔUCS4´úÂëµãΪµ¥Î»¡£
ÒÔÉϺ¯Êý·µ»Østring1Öаüº¬string2µÄλÖᣴÓ×ó±ß¿ªÊ¼É¨Ãèstring1,ÆðʼλÖÃÊÇA¡£Èç¹ûAΪ¸ºÊýÄÇô´ÓÓұ߿ªÊ¼É¨Ãè¡£µÚB´Î³öÏÖµÄλÖý«±»·µ»Ø¡£AºÍBȱʡ¶¼Îª1£¬¼´·µ»ØÔÚ
string1ÖеÚÒ»´Î³öÏÖstring2µÄλÖá£Èç¹ûstring2ÔÚAº ......
----use pubs-sales
-----´´½¨Ë÷Òý
create index index_name
on authors(au_lname)
--´´½¨Ë÷Òýºó±íÖÐËùÓеÄÊý¾Ý¸ú֮ǰûÓÐÇø±ð
select * from authors
--µ¥¶À²éË÷ÒýÁÐ
select au_lname from authors
--Ç¿ÖÆʹÓ÷Ǵؼ¯Ë÷Òý
select * from authors with(index(index_name))
--¶à×ֶηǴؼ¯Ë÷Òý
create inde ......
Èç¹ûÄÜ´Ó±¸·ÝÎļþÖÐÖ»»Ö¸´Ò»¸ö±íµÄÊý¾Ý£¬ÄDz»ÊǺܺÃÂ𣿱ÈÈ磬Ä㱸·ÝÁËAdventureWorksÊý¾Ý¿â£¬ÏÖµÄÄãÖ»»Ö¸´ÀïÃæVendor±íÊý¾Ý¡£²»ÐÒµÄÊÇ£¬SQL Server±¾Éí²¢²»Ö§³ÖÕâÑù»¹Ô£¬ÄãÐèÒª´ÓµÚÈý·½ÌṩµÄ¹¤¾ßÖÐÀ´Ö´ÐÐÕâÑùµÄÈÎÎñ¡£
ÌṩÕâÖÖ¹¦ÄܵijÌÐò¶¼ÊÇһЩSQL ServerµÚÈý·½±¸·Ý¹¤¾ß¡£ËüÃÇ¿ÉÒÔÈÃÄã´Ó±¸·ÝÎļþÖгéÈ¡»òÊǶÁÈ¡µ¥¸ö±í ......