dz̸SQL×¢Èë µ±unionÓöÉÏntextÊý¾ÝÀàÐÍ
ÔÚÎÒÃǽøÐÐsql×¢ÈëµÄ¹ý³ÌÖг£³£»áÓõ½union²éѯ·½·¨£¬´ó¶àÊýÇé¿öÏÂʹÓÃunion²éѯ·¨¿ÉÒÔÈÃÎÒÃǺܿìµÄÖªµÀÄ¿±êµÄÊý¾Ý×éÖ¯·½Ê½¡£È»¶øµ±ÎÒÃÇÓöµ½ntext¡¢text»òimageÊý¾ÝÀàÐÍʱ£¬union²éѯ¾Í²»Ì«¹ÜÓÃÁË¡£ÒÔsql serverΪÀý£¬ÔÚÕâÖÖÇé¿öÏ»áÅ׳öÈçÏ´íÎó£ºntext Êý¾ÝÀàÐͲ»ÄÜѡΪ DISTINCT£¬ÒòΪËü²»¿É±È¡£
ÕâÀÎÒÒÔsql serverÊý¾Ý¿âΪ²âÊÔ»·¾³À´½øÐзÖÎö¡£ÒòΪntext¡¢text¡¢imageÊý¾Ý×ֶοÉÄÜ´æ´¢·Ç³£¶àµÄÊý¾Ý£¬Ä¬ÈϵÄÇé¿öÏ£¬Êý¾Ý¿âΪÌá¸ßЧÂÊ»áÇ¿ÖÆÅųýÒÔÉÏÀàÐ͵Ä×Ö¶ÎÖеÄÏàͬµÄÊý¾Ý£¬ÕâÑù¾ÍÏ൱ÓÚÔÚsql²éѯÓï¾äÖмÓÈëÁËdistinct¹Ø¼ü×Ö¡£¶øÓÖÒòΪÕâÖÖÀàÐ͵ÄÊý¾ÝÁ¿¿ÉÄܷdz£´ó£¬Êý¾Ý¿âÎÞ·¨¶ÔÕâÖÖÀàÐ͵Ä×ֶνøÐÐÓÐЧµÄ±È½Ï£¬¶ødistinctÓÖÒªÇóÊý¾Ý¿â½øÐÐÊý¾Ý±È½Ï£¬´Ó¶øµ¼Ö´øÓÐunionrµÄsqlÓï¾äÖ´ÐдíÎó£¬Ôì³ÉÉÏÊöÏÖÏó¡£
Á˽âÁ˳ö´íµÄÔÀíÎÒÃǾͿÉÒÔÔÚÖ´µÈµÄsqlÓï¾äÖмÓÈëÏàÓ¦µÄÌõ¼þÀ´Ê¹sqlÄÜÕýÈ·Ö´ÐС£´ÓÉÏÃæ¿ÉÒÔ¿´³ö£¬sqlÓï¾äÎÞ·¨Ö´ÐеÄÔÒòÊÇÒòΪÊý¾Ý¿âÈ¥¼ì²éunionµÄÊý¾ÝÊÇ·ñÏàͬ£¬ÄÇôÎÒÃÇÖ»ÐèҪȥµôÕâ¸öĬÈϵÄÌõ¼þ¾Í¿ÉÒÔÁË¡£½â¾öµÄ·½·¨¾ÍÊÇÔÚunion¹Ø¼ü×Öºó±ß¼ÓÉÏ“all”¹Ø¼ü×Ö¡£
ÏÂÃæÓÃʵÀýÀ´ÑÝʾÕâÖÖÀàÐ͵Äunion×¢Èë¡£Ê×ÏÈ´´½¨Á½¸ö±í£º
CREATE TABLE [dbo].[ntextTest](
[id] [int] NOT NULL,
[name] [nchar](10) NULL,
[target] [ntext] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
CREATE TABLE [dbo].[support](
[col1] [nchar](10) NULL,
[col2] [nchar](10) NULL
) ON [PRIMARY]
È»ºó·Ö±ðÔÚÕâÁ½¸ö±íÖвåÈëÊý¾Ý£º
insert into ntextTest values(1,'aaa','adfsfs')
insert into ntextTest values(2,'test','aaaa')
insert into support values('aa','bb')
Ö®ºóÖ´ÐÐÏÂÁвéѯ£º
select * from ntextTest union select 1,2,col1 from support
Ò»Èç¼´Íù£¬Ã»Óгɹ¦¡£ÔÙÖ´ÐУº
select * from ntextTest union all select 1,col1,col2 from support
Õâ´ÎÕý³£·µ»Ø½á¹û£¡½ÓÏÂÀ´±»¿¨×¡µÄsql×¢Èë¿ÉÒÔ¼ÌÐø½øÐÐÁË¡£
ÉÏÃæËù½²µÄÎÊÌâµÄÇ°ÌáÊÇntext¡¢text¡¢imageµÈÊý¾ÝÀàÐͳöÏÖÔÚunion²éѯµÄÇ°Ã沿·Ö£¬ÔÚ½øÐÐsql×¢Èëʱ£¬×¢Èë¶ÔÏóÔÓеIJéѯÓï¾äÖаüº¬ntextÊý¾ÝÀàÐͼ´ÊÇÕâÖÖÇé¿ö¡£»¹ÓÐÁíÒ»ÖÖÇé¿öÊÇÔÚÎÒÃÇ×¢ÈëʱϣÍû²éѯntextÊý¾Ý×ֶεÄÄÚÈÝ¡£ÕâÖÖÇé¿ö»¹ÓÐÒÔÓÐÁíÒ»ÖÖ²Ù×÷·½
Ïà¹ØÎĵµ£º
×î½üÁ½ÌìÒ»Ö±ÔÚÕÛÌÚSQLÓï¾ä£¬Ã»°ì·¨£¬Ð´Êý¾Ý¿âµÄÐֵܸøÁËÁ½¸öÀý×ӾͲ»ÔÙ¹ÜÁË£¬¶øÇÒ×î½üÇë¼ÙÁË¡£½ñÌì¼Ó°à»¹ÊÇÕÛÌÚÕâôһ¸öÓï¾ä£¬×ÜÊDz»¶Ô£¬ÇëÀÏ´ó¿´ÁË¿´»¹ÊÇû¿´³öÃŵÀÀ´£¬ ÔÚSQLite Expert Professional ÀïÃæдµÄÓï¾ä¶¼¿ÉÒÔÖ´Ðгɹ¦£¬µ«ÊÇÔÚAndroidµÄ¹¤³ÌÀïÃæÔõôÕÛÌھͲ»¶Ô¡£ ÓôÃÆ°¡£¬½ñÌì¼Ó°àËãÊÇ°×¼ÓÁË¡£
ΪÁ˲éÕÒºÍÑ§Ï ......
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'CLR', 0
GO
-- To update the currently configured value for this feature.
......
×÷Õß: cnd8, ¡¡³ö´¦:ITר¼ÒÍøÂÛ̳,¡¡ÔðÈαà¼: ³Â×Óç÷,¡¡2010-04-21 13:00 ¡¡¡¡ÏÖÔÚÐèÒªÔÚһ̨·þÎñÆ÷(A)ÉϵÄÊý¾Ý¿â(Master)Àï·ÃÎÊÁíÍâһ̨·þÎñÆ÷(B)µÄÁíÍâÁ½¸öÊý¾Ý¿â(NZ ºÍ AU)¡£AU ºÍ NZ ÊÇÍøÕ¾µÄ²¿·ÖʵʱÊý¾Ý£¬Ä¿Ç°Ä³Ò»²½²Ù×÷µÄREPLICATION·½°¸ÊÇ´Ó·þÎñÆ÷Bµ½A£¬AU / NZ µÄ±í½á¹¹Í¬Master Êý¾Ý½á¹¹»ù±¾Ò»Ö¡£¡¡¡¡ÏÖÔÚÐèÒªÔ ......
¡¡¡¡(1)ÕûºÏ¼òµ¥,ÎÞ¹ØÁªµÄÊý¾Ý¿â·ÃÎÊ£º
¡¡¡¡Èç¹ûÄãÓм¸¸ö¼òµ¥µÄÊý¾Ý¿â²éѯÓï¾ä,Äã¿ÉÒÔ°ÑËüÃÇÕûºÏµ½Ò»¸ö²éѯÖÐ(¼´Ê¹ËüÃÇÖ®¼äûÓйØϵ)
¡¡¡¡(2)ɾ³ýÖظ´¼Ç¼£º
¡¡¡¡×î¸ßЧµÄɾ³ýÖظ´¼Ç¼·½·¨ ( ÒòΪʹÓÃÁËROWID)Àý×Ó£º
¡¡¡¡DELETE from EMP E WHERE E.ROWID > (SELECT MIN(X. ......