ÈçºÎ²éѯ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
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
ÄÚÈÝÕªÒª£ºÔÚPL/SQL¿ª·¢¹ý³ÌÖУ¬Ê¹ÓÃSQL£¬PL/SQL¿ÉÒÔʵÏִ󲿷ݵÄÐèÇ󣬵«ÊÇÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÔÚPL/SQLÖÐʹÓñê×¼µÄSQLÓï¾ä»òDMLÓï¾ä²»ÄÜʵÏÖ×Ô¼ºµÄÐèÇ󣬱ÈÈçÐèÒª¶¯Ì¬½¨±í»òij¸ö²»È·¶¨µÄ²Ù×÷ÐèÒª¶¯Ì¬Ö´ÐС£Õâ¾ÍÐèҪʹÓö¯Ì¬SQLÀ´ÊµÏÖ¡£±¾ÎÄͨ¹ý¼¸¸öʵÀýÀ´ÏêϸµÄ½²½â¶¯Ì¬SQLµÄʹÓᣡ¡¡¡
¡¡¡¡±¾ÎÄÊÊÒ˶ÁÕß·¶Î§£ºOracle³ ......
Çë½Ì¸ßÊÖÒ»¸öÎÊÌ⣬ÎÊÌâÃèÊöÈçÏ£º
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¸öºÅÂë
Ç ......
µÚÒ»ÖÖ·½·¨£ºÊ¹ÓÃNVLº¯Êý´¦ÀíNULLÖµ¡£
ÆäÓï·¨¸ñʽÊÇNVL(exp1,exp2)¡£ÆäÖвÎÊýexp1ºÍexp2¿ÉÒÔʹÈÎÒâÊý¾ÝµÄÀàÐÍ£¬µ«Á½ÕßÊý¾ÝÀàÐͱØÐëÆ¥Å䡣ʾÀý£ºselect ename,sal,comm,sal+nvl(comm,0) as salary from emp;
µÚ¶þÖÖ·½·¨£ºÊ¹ÓÃNVL2º¯Êý´¦ÀíNULLÖµ¡£
ÆäÓï·¨¸ñʽÊÇNVL2(exp1,exp2,exp3)¡£ÕâÊÇoracle9iÐÂÔö¼ÓµÄº¯Êý¡£Èç¹ûexp1 ......
Èç¹ûÄÜ´Ó±¸·ÝÎļþÖÐÖ»»Ö¸´Ò»¸ö±íµÄÊý¾Ý£¬ÄDz»ÊǺܺÃÂ𣿱ÈÈ磬Ä㱸·ÝÁËAdventureWorksÊý¾Ý¿â£¬ÏÖµÄÄãÖ»»Ö¸´ÀïÃæVendor±íÊý¾Ý¡£²»ÐÒµÄÊÇ£¬SQL Server±¾Éí²¢²»Ö§³ÖÕâÑù»¹Ô£¬ÄãÐèÒª´ÓµÚÈý·½ÌṩµÄ¹¤¾ßÖÐÀ´Ö´ÐÐÕâÑùµÄÈÎÎñ¡£
ÌṩÕâÖÖ¹¦ÄܵijÌÐò¶¼ÊÇһЩSQL ServerµÚÈý·½±¸·Ý¹¤¾ß¡£ËüÃÇ¿ÉÒÔÈÃÄã´Ó±¸·ÝÎļþÖгéÈ¡»òÊǶÁÈ¡µ¥¸ö±í ......