SQL Server2005 SynonymµÄʹÓÃ
--> Title : SQL Server2005 SynonymµÄʹÓÃ
--> Author : wufeng4552
--> Date : 2009-10-30
1.SynonymµÄ¸ÅÄî
¡¡ Synonym£¨Í¬Òå´Ê£©ÊÇSQL Server 2005µÄÐÂÌØÐÔ¡£¿ÉÒÔ¼òµ¥µÄÀí½âSynonymΪÆäËû對ÏóµÄ±ðÃû¡£
語·¨
CREATE SYNONYM [ schema_name_1. ] synonym_name FOR < object >
< object > :: =
{
[ server_name.[ database_name ] . [ schema_name_2 ].| database_name . [ schema_name_2 ].| schema_name_2. ] object_name
}
ÔÚ½¨Á¢Í¬義×Ö時£¬»ùµ×Îï¼þ²»ÐèÒª´æÔÚ¡£ÔÚ執ÐÐ階¶Î£¬SQL Server 會檢²é»ùµ×Îï¼þÊÇ·ñ´æÔÚ¡£
¸÷參數º義ÈçÏÂ:
schema_name_1 :Ö¸¶¨½¨Á¢Í¬義×ÖµÄ結構ÃèÊö¡£Èç¹ûδָ¶¨ schema£¬SQL Server 2005 會ʹÓÃĿǰʹÓÃÕßµÄ預設結構ÃèÊö¡£
synonym_name :這ÊÇÐÂͬ義×ÖµÄÃû稱¡£
server_name :這ÊÇ»ùµ×Îï¼þËùÔÚµÄËÅ·þÆ÷Ãû稱¡£
database_name :這ÊÇ»ùµ×Îï¼þËùÔÚµÄ資ÁÏ庫Ãû稱¡£Èç¹ûδָ¶¨ database_name£¬¾Í會ʹÓÃÄ¿Ç°資ÁÏ庫µÄÃû稱¡£
schema_name_2 :這ÊÇ»ùµ×Îï¼þµÄ結構ÃèÊöÃû稱¡£Èç¹ûδָ¶¨ schema_name£¬¾Í會ʹÓÃĿǰʹÓÃÕßµÄ預設結構ÃèÊö¡£
object_name :這ÊÇͬ義×Ö參¿¼µÄ»ùµ×Îï¼þÃû稱¡£
×¢:
ÈôҪʹÓøø¶¨¼Ü¹¹´´½¨Í¬Òå´Ê£¬Óû§±ØÐëÂú×ãÒÔÏÂÌõ¼þ£º
(1)ÓµÓд˼ܹ¹»ò¾ßÓÐ ALTER SCHEMA ȨÏÞÒÔ
(2)¾ßÓÐ CREATE SYNONYM ȨÏÞ¡£
(3)ÊÇ db_owner µÄ³ÉÔ±¡£
(4)ÊÇ db_ddladmin ¹Ì¶¨Êý¾Ý¿â½ÇÉ«µÄ³ÉÔ±
¿ÉÒÔΪÏÂÁжÔÏóÀàÐÍ´´½¨Í¬Òå´Ê£º
³ÌÐò¼¯ (CLR) ´æ´¢¹ý³Ì; ³ÌÐò¼¯ (CLR) ±íÖµº¯Êý
³ÌÐò¼¯ (CLR) ±êÁ¿º¯Êý; ³ÌÐò¼¯¾ÛºÏ (CLR) ¾ÛºÏº¯Êý
¸´ÖÆɸѡ¹ý³Ì; À©Õ¹´æ´¢¹ý³Ì
SQL ±êÁ¿º¯Êý;SQL ±íÖµº¯ÊýSQL ÄÚÁª±íÖµº¯Êý;
SQL ´æ´¢¹ý³ÌÊÓͼ; ±í(Óû§¶¨Òå)
2.SynonymµÄʵ¼ÊÓ¦ÓÃ
ÔÚÄãµÄ³ÌÐò·¢²¼µÄʱºò£¬ÄãͻȻ·¢ÏÖÄãÐèÒª¸ü¸Äij¸ö±íÃû£¬»ò×Ö¶ÎÃû¡£¶øÄãµÄ³ÌÐòÒѾ²»¿ÉÄÜÐ޸ġ£Õâʱ£¬Ôõô°ìÄØ£¿ÄǾʹ´½¨Synonym°É¡£µ±È»£¬ÔÚsql2000ʱ´ú£¬Äã¿ÉÒÔʹÓÃviewÀ´×öÕâ¸öÊÂÇ飬»òsprocs»òudfµÈ¡£µ«SynonymÓÐÆäËüËù²»ÄܵŦÄÜ£¬ÄǾÍÊÇ¿çÊý¾Ý¿â£¬¿ç·þÎñÆ÷¡£
-----------------------
Ïà¹ØÎĵµ£º
Ò»¡¢PL/SQL³öÏÖµÄÄ¿µÄ
¡¡¡¡½á¹¹»¯²éѯÓïÑÔ(Structured Query
Language£¬¼ò³ÆSQL)ÊÇÓÃÀ´·ÃÎʹØϵÐÍÊý¾Ý¿âÒ»ÖÖͨÓÃÓïÑÔ£¬ËüÊôÓÚµÚËÄ´úÓïÑÔ£¨4GL£©£¬ÆäÖ´ÐÐÌصãÊǷǹý³Ì»¯£¬¼´²»ÓÃÖ¸Ã÷Ö´ÐеľßÌå·½·¨ºÍ;
¾¶£¬¶øÊǼòµ¥µÄµ÷ÓÃÏàÓ¦Óï¾äÀ´Ö±½ÓÈ¡µÃ½á¹û¼´¿É¡£ÏÔÈ»£¬ÕâÖÖ²»¹Ø×¢ÈκÎʵÏÖϸ½ÚµÄÓïÑÔ¶ÔÓÚ¿ª·¢ÕßÀ´ËµÓÐ׿«´óµÄ ......
º¯Êý£º
XMLPARSE£º½âÎö×Ö·û»òÕß´ó¶ÔÏó¶þ½øÖÆÊý¾Ý£¬²úÉúXML
XMLSERIALIZE£º½«XMLֵת»»Îª×Ö·û»òÕß´ó¶ÔÏó¶þ½øÖÆÊý¾Ý
XMLVALIDATE£º¸ù¾ÝXML schemaУÑéXMLÖµµÄÓÐЧÐÔ
XMLEXISTS£º¼ì²âXQueryÊÇ·ñ·µ»Ø½á¹û£¨ÈçÓÉÒ»¸ö»ò¶à¸öÏîËù×é³ÉµÄÐòÁУ©
XMLQUERY£ºÖ´ÐÐÒ»¸öXQuery²¢ÒÔÒ»¸öÐòÁзµ»Ø½á¹û
XMLTABLE£ºÖ´ÐÐÒ»¸öXQuery£¬ÒÔ¹ØÏ ......
SQLÓï¾äµ¼Èëµ¼³ö´óÈ«
/******* µ¼³öµ½excel
EXEC master..xp_cmdshell ¡¯bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -S"GNETDATA/GNETDATA" -U"sa" -P""¡¯
/*********** µ¼ÈëExcel
SELECT *
from OpenDataSource( ¡¯Microsoft.Jet.OLEDB.4.0¡¯,
¡¯Data Source="c:\test.xls ......
1.²»ÓÃÍ˳öSQL2000°²×°³ÌÐò,Ö±½ÓÇл»µ½×ÀÃæ.
¡¡¡¡2.´ò¿ª×¢²á±í±à¼Æ÷£¨ÔÚ“ÔËÐДÖÐÇÃÈë“regedit”Ö®ºó»Ø³µ¼´¿É£©£¬¶¨Î»µ½×¢²á±íµÄHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager½Úµã.
¡¡¡¡3.µ¥»÷“Session Manager”Õâ¸ö½Úµã£¬ ......
Ò»¡¢Ê¹ÓòÎÊý»¯ÊäÈë¡£´æ´¢¹ý³ÌÀᄀÁ¿±ÜÃâÓï¾äÆ´½Ó¡£
¶þ¡¢¶ÔÓÚһЩÊý¾Ý¿â£¬±ØÐëÉèÖÃȨÏÞ£¬ÉõÖÁÉèÖõ½×ֶΡ£
Èý¡¢Ê¼ÖÕͨ¹ý²âÊÔÀàÐÍ¡¢³¤¶È¡¢¸ñʽºÍ·¶Î§À´ÑéÖ¤Óû§ÊäÈë¡£
ËÄ¡¢¹ýÂËÃô¸Ð×Ö·û¡£
Function ReplaceStr(Str)
Str=Trim(Str)
Str=Replace(Str,"'","'")
Str=Replace(Str,";",";")
Str=Rep ......