´ÓSQLÓïÑԵķÖÀà̸COMMITºÍROLLBACKµÄÓ÷¨
´Ó¹¦ÄÜÉÏ»®·Ö£¬SQLÓïÑÔ¿ÉÒÔ·ÖΪDDL,DMLºÍDCLÈý´óÀà¡£
1. DDL£¨Data Definition Language£©
Êý¾Ý¶¨ÒåÓïÑÔ£¬ÓÃÓÚ¶¨ÒåºÍ¹ÜÀí SQL Êý¾Ý¿âÖеÄËùÓжÔÏóµÄÓïÑÔ £»
CREATE---´´½¨±í
ALTER---Ð޸ıí
DROP---ɾ³ý±í
2. DML£¨Data Manipulation Language£©
Êý¾Ý²Ù×ÝÓïÑÔ£¬SQLÖд¦ÀíÊý¾ÝµÈ²Ù×÷ͳ³ÆΪÊý¾Ý²Ù×ÝÓïÑÔ £»
INSERT---Êý¾ÝµÄ²åÈë
DELETE---Êý¾ÝµÄɾ³ý
UPDATE---Êý¾ÝµÄÐÞ¸Ä
SELECT---Êý¾ÝµÄ²éѯ
DCL£¨Data Control Language£©
Êý¾Ý¿ØÖÆÓïÑÔ£¬ÓÃÀ´ÊÚÓè»ò»ØÊÕ·ÃÎÊÊý¾Ý¿âµÄijÖÖÌØȨ£¬²¢¿ØÖÆÊý¾Ý¿â²Ù×ÝÊÂÎñ·¢ÉúµÄʱ¼ä¼°Ð§¹û£¬¶ÔÊý¾Ý¿âʵÐмàÊӵȣ»
GRANT---ÊÚȨ¡£
ROLLBACK---»Ø¹ö
COMMIT---Ìá½»¡£
Ìá½»Êý¾ÝÓÐÈýÖÖÀàÐÍ£ºÏÔʽÌá½»¡¢ÒþʽÌá½»¼°×Ô¶¯Ìá½»¡£ÏÂÃæ·Ö±ð˵Ã÷ÕâÈýÖÖÀàÐÍ¡£
(1) ÏÔʽÌá½»
ÓÃCOMMITÃüÁîÖ±½ÓÍê³ÉµÄÌύΪÏÔʽÌá½»¡£
(2) ÒþʽÌá½»
ÓÃSQLÃüÁî¼ä½ÓÍê³ÉµÄÌύΪÒþʽÌá½»¡£ÕâЩÃüÁîÊÇ£º
ALTER£¬AUDIT£¬COMMENT£¬CONNECT£¬CREATE£¬DISCONNECT£¬DROP£¬
EXIT£¬GRANT£¬NOAUDIT£¬QUIT£¬REVOKE£¬RENAME¡£
(3) ×Ô¶¯Ìá½»
Èô°ÑAUTOCOMMITÉèÖÃΪON£¬ÔòÔÚ²åÈë¡¢Ð޸ġ¢É¾³ýÓï¾äÖ´Ðкó£¬
ϵͳ½«×Ô¶¯½øÐÐÌá½»£¬Õâ¾ÍÊÇ×Ô¶¯Ìá½»¡£Æä¸ñʽΪ£º SQL>SET AUTOCOMMIT ON£»
COMMIT / ROLLBACKÕâÁ½¸öÃüÁîÓõÄʱºòҪСÐÄ¡£ COMMIT / ROLLBACK ¶¼ÊÇÓÃÔÚÖ´ÐÐ DMLÓï¾ä£¨INSERT / DELETE / UPDATE / SELECT £©Ö®ºóµÄ¡£DML Óï¾ä£¬Ö´ÐÐÍêÖ®ºó£¬´¦ÀíµÄÊý¾Ý£¬¶¼»á·ÅÔڻعö¶ÎÖУ¨³ýÁË SELECT Óï¾ä£©£¬µÈ´ýÓû§½øÐÐÌá½»£¨COMMIT£©»òÕ߻عö £¨ROLLBACK£©£¬µ±Óû§Ö´ÐÐ COMMIT / ROLLBACKºó£¬·ÅÔڻعö¶ÎÖеÄÊý¾Ý¾Í»á±»É¾³ý¡£
£¨SELECT Óï¾äÖ´Ðкó£¬Êý¾Ý¶¼´æÔÚ¹²Ïí³Ø¡£Ìṩ¸øÆäËûÈ˲éѯÏàͬµÄÊý¾Ýʱ£¬Ö±
Ïà¹ØÎĵµ£º
Ê×ÏȽéÉÜÒ»ÏÂʲôÊÇ´æ´¢¹ý³Ì£º´æ´¢¹ý³Ì¾ÍÊǽ«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´£¬²¢ÇÒÕâÑùµÄÓï¾äÊÇ·ÅÔÚÊý¾Ý¿âÖеģ¬»¹¿ÉÒÔ¸ù¾ÝÌõ¼þÖ´Ðв»Í¬SQLÓï¾ä£¬ ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ£¬Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî¡£
¡¡¡¡Çë´ó¼ÒÀ´Á˽âһϴ洢¹ý³Ìµ ......
´´½¨sqlÊý¾Ý¿â¸´ÖƵķ¢²¼¡¢¶©ÔĵÄÎÊÌâ´¦Àí[ת]
²Ù×÷ʹÓõÄһЩ¼¼ÇÉ(ÊÂÎñ¸´ÖÆÀàÐÍ):
1.ÈçºÎÐÞ¸ÄÒ»¸öÒѾ·¢²¼µÄ±íµÄÊôÐÔ?
½«·¢²¼ËùÓж©ÔÄɾ³ý,(·¢²¼²»ÓÃɾ³ý),¾Í¿ÉÒÔÔÚ·¢²¼ÊôÐÔµÄÏîÄ¿ÖÐÈ¡Ïû±í,È»ºó¾Í
¿ÉÒÔÐÞ¸ ......
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select
CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100),
GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3):
16/05/06
Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06
Select
CON ......
HexString to Binary:
DECLARE @y CHAR(34)
SET @y = '0x499104dc92dd27499da9ad8f56dcb437'
DECLARE @x BINARY(16)
DECLARE @sql NVARCHAR(200)
SET @sql = 'SELECT @x = ' + @y
EXEC sp_executesql
@sql,
N'@x BINARY(16) OUTPUT',
@x OUTPUT
SELECT @x
Binary to HexString:
DECLARE @a VARBINARY(20)
SET ......
ÎÒÃÇÒª½¨Á¢¶à¼¶¹Øϵ£¬Ê×ÏÈÐèÒªÁ½¸ö±í.
µÚÒ»¸ö±í±íʾֱÊô½á¹¹£¬±ÈÈç˵ÎÒÃǹ«Ë¾ÓÐÒ»¸ö²¿ÃÅ¡£¶øÕâ¸ö²¿ÃÅÏ»¹ÓÐ3¸öС×飬ÄÇô3¸öС×éÊôÓÚÕâ¸ö²¿ÃÅ.µÚ¶þ¸ö±í±íʾ¶à²ã½á¹¹,¾ÍÏóµÚÒ»±íÀïÃæËù±íʾµÄ£¬ÕâÈý¸öС×éͬʱ»¹ÊôÓÚ¹«Ë¾.¶øÕâ¸ö¹«Ë¾Í¬Ê±ÊôÓÚÕâ3¸öС×éµÄ¸¸¼¶µÄ¸¸¼¶µÄ²¿ÃÅ¡£¼ÙÈçÎÒ ......