SQL SERVERʹÓÃÊÂÎñÈÕÖ¾»Ö¸´Êý¾ÝµÄʵÑé
/*
ʹÓÃÊÂÎñÈÕÖ¾»Ö¸´Êý¾ÝµÄʵÑé
*/
--1.´´½¨²âÊÔÊý¾Ý¿â
CREATE DATABASE Db_test
ON
( NAME = Db_test_DATA,
FILENAME = 'c:\Db_test.mdf' )
LOG ON
( NAME = Db_test_LOG,
FILENAME = 'c:\Db_test.ldf')
GO
--2.¹ÊÕÏ»¹ÔÄ£ÐÍÉèÖÃΪfullÄ£ÐÍ,ĬÈϵļòµ¥Ä£Ðͱ¸·ÝÊÂÎñÈÕÖ¾ÊÇûÓõÄ
ALTER DATABASE Db_test SET RECOVERY FULL | BULK_LOGGED
--3.´´½¨²âÊÔ±í
CREATE TABLE [dbo].[BackupTabToTxt] (
[TabName] [varchar] (200) ,
)
--4.²åÈë²âÊÔÊý¾Ý
insert into BackupTabToTxt(TabName) values('test1')
insert into BackupTabToTxt(TabName) values('test2')
insert into BackupTabToTxt(TabName) values('test3')
select * from BackupTabToTxt
--5.±¸·ÝÊý¾Ý¿â
BACKUP DATABASE Db_test TO DISK='c:\test_data.bak'
--6.ɾ³ýÊý¾Ý,±¸·ÝÈÕÖ¾
delete from BackupTabToTxt where TabName='test3' --17:06
BACKUP LOG Db_test TO DISK='c:\test_log_1706.bak' --±¸·ÝÈÕÖ¾
delete from BackupTabToTxt where TabName='test2' --17:07
BACKUP LOG Db_test TO DISK='c:\test_log_1707.bak' --±¸·ÝÈÕÖ¾
select * from BackupTabToTxt
--7.ʹÓÃÊÂÎñÈÕÖ¾»Ö¸´Êý¾Ý
RESTORE database Db_test from DISK='c:\test_data.bak' WITH NORECOVERY
RESTORE LOG Db_test from DISK='c:\test_log_1706.bak' with stopat='2009-09-24 17:06' ,NORECOVERY
RESTORE LOG Db_test from DISK='c:\test_log_1707.bak' with stopat='2009-09-24 17:07'
select * from BackupTabToTxt
--8.ɾ³ý²âÊÔ¿â
drop database Db_test
Ïà¹ØÎĵµ£º
ÎÞÂÛÄúÊÇһλ SQL µÄÐÂÊÖ£¬»òÊÇһλֻÊÇÐèÒª¶Ô SQL ¸´Ï°Ò»ÏµÄ×ÊÁϲִ¢Òµ½çÀϽ«£¬Äú¾ÍÀ´¶ÔµØ·½ÁË£¡
- SQL Ö¸Áî: SQL ÈçºÎ±»ÓÃÀ´´¢´æ¡¢¶ÁÈ¡¡¢ÒÔ¼°´¦ÀíÊý¾Ý¿âÖ®ÖеÄ×ÊÁÏ¡£
- ±í¸ñ´¦Àí: SQL ÈçºÎ±»ÓÃÀ´´¦ÀíÊý¾Ý¿âÖеıí¸ñ¡£
- SQLÓï·¨: ÕâÒ»Ò³ÁгöËùÓÐÔÚÕâ¸ö½Ì²ÄÖб»Ìáµ½µÄ SQL Óï·¨
SQL SELECT
Store_Information ±í¸ñ ......
sql ºÜ¾Ã²»Óã¬Í»È»¼äÒªÇó×ö±¨±í¡£ËùÒÔÓÖ¿ÉÒÔ²¹Ò»²¹sql֪ʶÁË¡£µ«¾³£»áÓöµ½Ò»Ð©ÈõÖÇÎÊÌâ.
дÁËÒ»Ìõsql£ºselect to_date('2009-09-24 12:20:0') Äܽ«¸Ä×Ö·û´®×ª»»ÎªÈÕÆÚ
µ«ÁíÍâÒ»Ìõsqlȴת»»²»ÁË...¸Ð¾õºÜÆæ¹Ö.ÓÚÊǺõ¡£ÔÙ×Ðϸ¿´Ò»±é ·¢ÏÖ
¸øÒ»¸öÈÕÆÚ×Ö¶ÎÉèÖñðÃûʱÉèÖóÉÁËsib.fbizDate as dateÎÒ×Ô¼º¶¼ÎÞÓïÁË¡£Ôõô»áÉè ......
Ò» sqlÓï¾äµÄÖ´Ðв½Öè
1£©Óï·¨·ÖÎö£¬·ÖÎöÓï¾äµÄÓï·¨ÊÇ·ñ·ûºÏ¹æ·¶£¬ºâÁ¿Óï¾äÖи÷±í´ïʽµÄÒâÒå¡£
2£© ÓïÒå·ÖÎö£¬¼ì²éÓï¾äÖÐÉæ¼°µÄËùÓÐÊý¾Ý¿â¶ÔÏóÊÇ·ñ´æÔÚ£¬ÇÒÓû§ÓÐÏàÓ¦µÄȨÏÞ¡£
3£©ÊÓͼת»»£¬½«Éæ¼°ÊÓͼµÄ²éѯÓï¾äת»»ÎªÏàÓ¦µÄ¶Ô»ù±í²éѯÓï¾ä¡£
4£©±í´ïʽת»»£¬ ½«¸´Ô SQL ±í´ïʽת»»Îª½Ï¼òµ¥µÄµÈЧÁ¬½Ó±í´ïʽ¡ ......
--1.ÔÚÄ¿±ê·þÎñÆ÷ÉϽ¨Á¢Èç϶ÔÏó(±»Í¬²½µÄ·þÎñÆ÷)
if exists (select * from dbo.sysobjects where id = object_id(N'[sys_syscomments_bak]') and OBJECTPROPERTY(id, N'IsUserTable')   ......