¹ÜÀí SQL Server µÄÊÂÎñÈÕÖ¾
ÎÄÕÂÀ´Ô´£ºHttp://www.simple-talk.com
ÔÎĵØÖ·£ºhttp://www.simple-talk.com/sql/learn-sql-server/managing-transaction-logs-in-sql-server/
Ô×÷ÕߣºRobert Sheldon
·Ò룺Èý½úÒ»Ö¦»¨
ÒëÎÄÔµØÖ·£ºhttp://prj.souty.cn/Admin/Knowledges/ShowKnowledge.aspx?id=44dbde74-d2c5-41a5-a8e9-375ba7103025
ÔÚ SQL Server ʵÀýÖеÄÿһ¸öÊý¾Ý¿â£¬¶¼ÓÐÒ»¸öÈÕÖ¾£¬Ëü¼Ç¼×ÅÊý¾Ý¿âµÄËùÓиü¸Ä¡£ÓÉÓÚÕâ¸öÈÕÖ¾ÊǶÀÁ¢µÄ£¬ÔÚ¸ü¸Ä·¢Éú֮ǰ£¬ÊÂÎñÈÕÖ¾ÔÊÐíÔÚÓ²¼þ¹ÊÕÏ»òÓ¦ÓóÌÐò´íÎóʱ£¬¶ÔÊý¾Ý¿â»Ø¹ö»ò±£´æÊÂÎñ¡£ÓÉÓÚËüµÄ½ÇÉ«µÄÖØÒªÐÔ£¬ÊÂÎñÈÕÖ¾±»±£´æÔÚÒ»¸ö»ò¶à¸öÓëÊý¾Ý¿âÎļþ¶ÀÁ¢µÄÈÕÖ¾ÎļþÖУ»ÈÕÖ¾¼Ç¼ÊÇÔÚÄÚÈݵıä¸ü´Ó»º´æдµ½Êý¾Ý¿âÎļþÖÐÒÔÇ°·¢ÉúµÄ¡£
¶Ôÿ¸öÊý¾Ý¿â£¬ÊÂÎñÈÕÖ¾Ö§³ÖÒÔϲÙ×÷£º
µ±·¢³öÒ»¸ö»Ø¹ö²Ù×÷»òÊý¾Ý¿âÒýÇæ¼ì²âµ½Ò»¸ö´íʱ£¬½øÐÐÊÂÎñ»Ø¹ö£»
µ±·þÎñÆ÷ʧ¸Äʱ£¬½øÐÐÒ»¸öÍêÕûµÄÊÂÎñ»Ø¹ö¡£Õâ¸öÊÂÎñÔÚSQL Server ÖØÆôʱ½øÐлعö¡£
µ±·þÎñÆ÷ʧ°Üʱ£¬½«Î´Íê³ÉµÄÊÂÎñдÈëµ½ÈÕÖ¾Îļþ£¬¶ø²»ÊÇÊý¾ÝÎļþÖС£µ± SQL Server ÖØÆôʱ£¬ÕâЩδÍê³ÉµÄÊÂÎñ½«»áдÈëÊý¾ÝÎļþ¡£
µ±·¢ÉúÓ²¼þ´íÎóʱ£¬¶Ô»Ö¸´µÄÊý¾Ý¿â¡¢Îļþ×é¡¢Îļþ»òÒ³ÏòÇ°¹ö¶¯µ½Ê§°Üµã¡£ÊÂÎñ½«¹ö¶¯µ½×îºóÒ»¸öÍêÕû±¸·Ý»ò²îÒ챸µã¡£
¶ÔÊÂÎñ¸´ÖÆ¡¢Êý¾Ý¿â¾µÏñ¡¢ÈÕÖ¾´«ÊäÌṩ֧³Ö¡£
ÕâЩ¼Ç¼ÊÂÎñÈÕÖ¾µÄÎļþ£¬»áÓÉÊý¾Ý¿âÒýÇæ¸ù¾ÝÎïÀíÎļþµÄʵ¼ÊÇé¿ö£¬×Ô¶¯µØ·Ö½âΪ¶à¸öÐéÄâÎļþ¡£Êý¾Ý¿âÒýÇæÒ²»áÅжÏÔÚºÎʱ¶ÔÄÄЩÐéÄâÎļþ½øÐнضϡ£Äã¿ÉÒÔÖ¸¶¨ÎïÀíÈÕÖ¾ÎļþµÄ×îСֵºÍ×î´óÖµ£¬²¢¿ÉÒÔÅäÖÃÀ©Õ¹ÎļþʱµÄÔö³¤ÂÊ¡£ÁíÍ⣬Äã¿ÉÒÔÏòÈÕÖ¾Ôö¼ÓÎïÀíÎļþ¡¢É¾³ýÎļþ¡¢Ôö¼ÓÈÕÖ¾µÄ´óС»òÊÕËõÈÕÖ¾¡£
ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«½âÊÍÈçºÎÖ´ÐÐÕâЩÈÎÎñ£¬ÒÔ¿ªÊ¼¹ÜÀíÄãµÄÊÂÎñÈÕÖ¾£¬Í¬Ê±£¬ÎÒÌṩÁËһЩÀý×ÓÒÔÑÝʾÿһ¸öÈÎÎñÈçºÎ¹¤×÷¡£ÔÚÕâЩÀý×ÓÖУ¬ÎÒʹÓÃλÓÚ±¾µØ SQL Server 2008 ʵÀýÉ쵀 EmplyeeDb Êý¾Ý¿â£º
USE master;
IF EXISTS
(
SELECT name from sys.databases
WHERE name = 'EmployeeDB'
)
DROP DATABASE EmployeeDB;
CREATE DATABASE EmployeeDB
ON
(
NAME = EmployeeDB_dat,
FILENAME = 'C:\SqlData\EmployeeDb.mdf'
)
LOG ON
(
NAME = EmployeeDB_log,
FILENAME = 'C:\SqlData\EmployeeDb.ldf'
);
×¢Ò⣺ÎÒÊÇÔÚÒ»¸öÖ¸¶¨µÄλÖÃÉÏ´´½¨ÁËÒ»¸öÊý¾Ý¿âÎļþ£¬¶ø²»
Ïà¹ØÎĵµ£º
¹ØÓÚSQL×¢Èë(SQL Injection)µÄ·½·¨Æäʵ¶¼ºÜÆÕ±éºÍʹÓ㬹éÄÉÆðÀ´Ò²ºÜ·½±ã¡£Ò»°ã“ºÚ¿Í”ʹÓõÄÊÇÏֳɵŤ¾ßÈç“WEBÅÔ×¢¡¢°¢DÍøÂ繤¾ß°ü¡¢½ÌÖ÷XXX”µÈÕâЩ¶¼ÊǼ¯³ÉÁË
һЩ³£ÓõÄsql×¢ÈëÓï¾ä¡£ÏÂÃæÎÒ½«½éÉÜÈçºÎʹÓÃÊÖ¹¤×¢ÈëMYSQL,MSSQLÊý¾Ý¿â.
Ò»°ã©¶´²ú ......
---------Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast(-1.002 as int) v ......
ÓÐʱºò£¬ÔÚ¹¤×÷ÖлáÓöµ½½«Ò»¸öÊý¾Ý¿âÖбíµÄÊý¾Ýµ¼µ½ÁíÒ»¸öÊý¾Ý¿âµÄ±íÖУ¬µ«Êǹ¤¾ßÓÖûÓÐÌṩÕâÑùµÄ¹¦ÄÜ
ÏÂÃæÄÜͨ¹ýSQLÓï¾äÉú³ÉInsertÓï¾ä£¬ÔÙ²åÈëµ½ÁíÒ»¸öÊý¾Ý¿âÖС£
MSSQL:
SELECT 'INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension)'+
' VALUES('''+a.UserName+''','''+a.CardId+''','''+a.Ad ......
ת×Ôhttp://lavasoft.blog.51cto.com/62575/23373
SQLÓïÑÔµÄCASEÓï¾ä±¸Íü
¸ÅÊö£º
SQLÓï¾äÖеÄCASEÓï¾äÓë¸ß¼¶ÓïÑÔÖеÄswitchÓï¾ä£¬ÊDZê×¼SQLµÄÓï·¨£¬ÊÊÓÃÓëÒ»¸öÌõ¼þÅжÏÓжàÖÖÖµµÄÇé¿öÏ·ֱðÖ´Ðв»Í¬µÄ²Ù×÷¡£Áé»îÓ¦ÓÃCASEÓï¾ä¿ÉÒÔʹSQLÓï¾ä±äµÃ¼ò½àÒ׶Á£¬ÏÂÃæÔÚDB2»·¾³ÏÂͨ¹ýÒ»¸ö¼òµ¥µÄ²éѯÀ´Õ¹Ê¾SQL CASEÓ ......