ʹÓÃTRY/CATCHÓï¾ä½â¾öSQL Server 2005ËÀËø
ÈÃÎÒÃÇ´ÓÕâÑùÒ»¸öʾÀý¿ªÊ¼ËµÆð£¬ËüÔÚ SQL Server 2000 ºÍ 2005 Öж¼ÄÜÒýÆðËÀËø¡£ÔÚ±¾ÎÄÖУ¬ÎÒʹÓà SQL Server 2005 µÄ×îРCTP£¨ÉçÇø¼¼ÊõÔ¤ÀÀ£¬Community Technology Preview£©°æ±¾£¬SQL Server 2005 Beta 2£¨7 Ô·¢²¼£©Ò²Í¬ÑùÊÊÓá£Èç¹ûÄúûÓÐ Beta 2 »ò×îÐ嵀 CTP °æ±¾£¬ÇëÏÂÔØ SQL Server 2005 Express µÄ×îа汾£¬ÓÃËüÀ´½øÐÐÊÔÑé¡£
¿ÉÄÜ·¢ÉúµÄËÀËøÇé¿öÓкܶ࣬[²ÎÔÄhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_con_7a_3xrf.aspÒÔ¼°ËÀËøÎÄÕÂÊ÷ÖеĺóÐøÎÄÕ¡£— ±àÕß ]£¬µ«×îÓÐȤ¡¢×î΢ÃîµÄÊÇÄÇЩ¹ØÓÚÔĶÁÆ÷ºÍ±àдÆ÷»¥Ïà×èÈûµÄËÀËø¡£ÒÔÏ´úÂëÔÚ pubs Êý¾Ý¿âÖоͲúÉúÁËÕâÑùÒ»¸öËÀËø¡££¨Äú¿ÉÒÔÔÚ SQL Server 2000 µÄÁ½¸ö Query Analyzer ´°¿ÚÖлò SQL Server 2005 µÄÁ½¸ö Management Studio queries Öв¢ÁÐÔËÐÐÕâ¶Î´úÂë¡££©ÔÚÆäÖÐÒ»¸ö´°¿ÚÖеĴúÂëÕýÎÄÇ°ÃæÌí¼ÓÏÂÁÐÓï¾ä£º
-- Window 1 header
DECLARE @au_id varchar(11), @au_lname varchar(40)
SELECT @au_id = '111-11-1111', @au_lname = 'test1'
ÔÚµÚ¶þ¸ö´°¿ÚÖÐÌí¼ÓÏÂÁÐÓï¾ä£¬½øÐеڶþ´ÎÁ¬½Ó£º
-- Window 2 header
DECLARE @au_id varchar(11), @au_lname varchar(40)
SELECT @au_id = '111-11-1112', @au_lname = 'test2'
ÔÚÁ½¸ö´°¿ÚÖж¼Ê¹ÓÃÏÂÁÐÓï¾ä×÷Ϊ´úÂëÕýÎÄ£º
-- Body for both connections:
BEGIN TRANSACTION
INSERT Authors VALUES
(@au_id, @au_lname, '', '', '', '', '', '11111', 0)
WAITFOR DELAY '00:00:05'
SELECT *
from authors
WHERE au_lname LIKE 'Test%'
COMMIT
ÔÚµÚÈý¸ö´°¿ÚÖÐÔËÐÐÏÂÁÐÓï¾ä£¬È·±£ authors ±í¸ñÖÐûÓÐÈκΰüº¬ÒÔÏ id µÄÊý¾Ý£º
DELETE from authors WHERE au_id = '111-11-1111'
DELETE from authors WHERE au_id = '111-11-1112'
ÔÚ 5 ÃëÖÓÄÚͬʱִÐд°¿Ú 1 ºÍ ´°¿Ú 2¡£ÒòΪÿ¸ö´°¿Ú¶¼ÒªµÈ´ýÖÁÉÙ 5 ÃëÖÓµÄʱ¼ä²ÅÄÜ·¢³ö SELECT Óï¾ä£¬ËùÓÐÿ¸öÁ¬½Ó¶¼½«Íê³É INSERT ²Ù×÷£¬ÕâÑù¾Í±£Ö¤ÁËÁ½¸ö´°¿ÚÖÐµÄ INSERT ²Ù×÷ÔÚ¸÷×﵀ SELECT Óï¾ä·¢²¼Ç°¾ÍÒѾÍê³ÉÁË¡£Ã¿¸ö´°¿ÚÖÐµÄ SELECT Óï¾ä¶¼³¢ÊÔ¶ÁÈ¡ authors ±í¸ñÖеÄËùÓÐÊý¾Ý£¬²éÕÒ au_lname ×Ö¶ÎÖµÖÐÀàËÆ“Test%”¸ñʽµÄÊý¾Ý¡£Òò´Ë£¬Á½¸ö´°¿ÚÖÐµÄ SELECT Óï¾ä¶¼½«³¢ÊÔ¶ÁÈ¡¸÷×ÔÁ¬½ÓÖеIJåÈëÊý¾Ý — Ò²¶ÁÈ¡¶Ô·½Á¬½ÓÖеIJåÈëÊý¾Ý¡£
read COMMITTED ¸ôÀ뼶±ðͨ¹ý·¢²¼¹
Ïà¹ØÎĵµ£º
--> Title : SQL Server 2005EXCEPTºÍINTERSECTÔËËã·û
--> Author : wufeng4552
--> Date : 2009-10-30
(Ò»)¸ÅÄî
EXCEPTºÍINTERSECTÔËËã·ûʹÄú¿ÉÒԱȽÏÁ½¸ö»ò¶à¸öSELECTÓï¾äµÄ½á¹û²¢·µ»Ø·ÇÖظ´Öµ¡£
(¶þ)區別
EXCEPTÔËËã·û·µ»ØÓÉEXCEPTÔËËã·û×ó²àµÄ²éѯ·µ»Ø¡¢¶øÓÖ² ......
΢ÈíµÄÒ»¸öMicrosoft Visual Studio International Pack v1.0£¬ÀïÃæ¾ÍÓÐÖÐÎÄ×Ö´¦Àí¹¦ÄÜ£¬»¹±È½Ï·á¸»£¬ÕâÀïÖ»Óüò·±×ª»»¡£Microsoft Visual Studio International Pack v1.0µÄÏÂÔصØÖ·£ºhttp://download.microsoft.com/download/5/7/3/57345088-ACF8-4E9B-A9A7-EBA35452DEF2/vsintlpack1.zip¡£½âѹ֮ºó°²×°CHTC ......
µ±ÎÒÃÇÓÃoracleµÄSQL*Plus¹¤¾ßÊäÈësqlÓï¾äµÄʱºò£¬SQL*PlusµÄĬÈÏÉèÖÃ×ÜÓÐЩ²»ºÏÀíµÄµØ·½£¬´ËʱÎÒÃÇͨ¹ýÒÔÏÂһЩ·½·¨¸Ä½ø£º
1¡¢¿ÉÒÔÔËÓÃSQL*Plus×ÔÉíһЩÓï¾ä¸Ä±ä»·¾³²ÎÊý¡£
SQL> set linesize 900 ; /* ¸ü¸ÄÏÔʾµÄ¿í¶È, ÉèÖóÉ900ºó, Ò»ÐÐÊý¾Ý¾Í²»»á·ÖÁ½ÐÐÏÔʾÁË */
&nb ......
SQLÓï¾äÏÈǰдµÄʱºò£¬ºÜÈÝÒ×°ÑһЩÌØÊâµÄÓ÷¨Íü¼Ç£¬ÎÒÌØ´ËÕûÀíÁËÒ»ÏÂSQLÓï¾ä²Ù×÷£¬·½±ã×Ô¼ºÐ´SQLʱ·½±ãÒ»µã£¬ÏëÌùÉÏÀ´£¬Ò»Æð¿´¿´£¬Í¬Ê±Ï£Íû´ó¼ÒÄܹ²Í¬¶à¶àÌáÒâ¼û£¬Ò²¸øÎÒÁôһЩ¸üºÃµÄ¼Ñ¾ä£¬ÕûÀíÒ»·Ý¡¶¾«ÃîSQLËÙ²éÊֲᡷ£¬²»Áߴͽ̣¡
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾ ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE data ......