ÊÓͼµÄ´´½¨¼°Ê¹ÓÃ(sql server 2005)
ÊÓͼµÄ´´½¨¼°Ê¹ÓÃ(sql server 2005)
´´½¨Ò»¸öÐéÄâ±í£¬¸Ã±íÒÔÒ»ÖÖ±¸Ó÷½Ê½Ìṩһ¸ö»ò¶à¸ö±íÖеÄÊý¾Ý¡£CREATE VIEW ±ØÐëÊDzéѯÅú´¦ÀíÖеĵÚÒ»ÌõÓï¾ä¡£
Transact-SQL Óï·¨Ô¼¶¨
Óï·¨
CREATE VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ]
[ WITH <view_attribute> [ ,...n ] ]
AS select_statement [ ; ]
[ WITH CHECK OPTION ]
<view_attribute> ::=
{
[ ENCRYPTION ]
[ SCHEMABINDING ]
[ VIEW_METADATA ] }
±¸×¢
Ö»ÄÜÔÚµ±Ç°Êý¾Ý¿âÖд´½¨ÊÓͼ¡£ÊÓͼ×î¶à¿ÉÒÔ°üº¬ 1,024 ÁС£
ͨ¹ýÊÓͼ½øÐвéѯʱ£¬Êý¾Ý¿âÒýÇæ ½«½øÐмì²éÒÔÈ·±£Óï¾äÖÐÈκÎλÖñ»ÒýÓÃËùÓÐÊý¾Ý¿â¶ÔÏ󶼴æÔÚ£¬ÕâЩ¶ÔÏóÔÚÓï¾äµÄÉÏÏÂÎÄÖÐÓÐЧ£¬ÒÔ¼°Êý¾ÝÐÞ¸ÄÓï¾äûÓÐÎ¥·´ÈκÎÊý¾ÝÍêÕûÐÔ¹æÔò¡£Èç¹û¼ì²éʧ°Ü£¬½«·µ»Ø´íÎóÏûÏ¢¡£Èç¹û¼ì²é³É¹¦£¬Ôò½«²Ù×÷ת»»Îª¶Ô»ù´¡±íµÄ²Ù×÷¡£
Èç¹ûij¸öÊÓͼÒÀÀµÓÚÒÑɾ³ýµÄ±í£¨»òÊÓͼ£©£¬Ôòµ±ÓÐÈËÊÔͼʹÓøÃÊÓͼʱ£¬Êý¾Ý¿âÒýÇæ ½«²úÉú´íÎóÏûÏ¢¡£Èç¹û´´½¨ÁËбí»òÊÓͼ£¨¸Ã±íµÄ½á¹¹ÓëÒÔÇ°µÄ»ù±íûÓв»Í¬Ö®´¦£©ÒÔÌ滻ɾ³ýµÄ±í»òÊÓͼ£¬ÔòÊÓͼ½«ÔٴοÉÓá£Èç¹ûбí»òÊÓͼµÄ½á¹¹·¢Éú¸ü¸Ä£¬Ôò±ØÐëɾ³ý²¢ÖØд´½¨¸ÃÊÓͼ¡£
´´½¨ÊÓͼʱ£¬ÓëÊÓͼÓйصÄÐÅÏ¢½«´æ´¢ÔÚÏÂÁÐĿ¼ÊÓͼÖУºsys.views¡¢sys.columns ºÍ sys.sql_dependencies¡£CREATE VIEW Óï¾äµÄÎı¾½«´æ´¢ÔÚ sys.sql_modules Ŀ¼ÊÓͼÖС£
¶Ôͨ¹ý numeric »ò float ±í´ïʽ¶¨ÒåµÄÊÓͼʹÓÃË÷ÒýËùµÃµ½µÄ²éѯ½á¹û£¬¿ÉÄܲ»Í¬ÓÚ²»¶ÔÊÓͼʹÓÃË÷ÒýµÄÀàËƲéѯËùµÃµ½µÄ½á¹û¡£ÕâÖÖ²îÒì¿ÉÄÜÊÇÓɶԻù´¡±í½øÐÐ INSERT¡¢DELETE »ò UPDATE ²Ù×÷ʱµÄÉáÈë´íÎóÒýÆðµÄ¡£
´´½¨ÊÓͼʱ£¬Êý¾Ý¿âÒýÇæ ½«±£´æ SET QUOTED_IDENTIFIER ºÍ SET ANSI_NULLS µÄÉèÖá£Ê¹ÓÃÊÓͼʱ£¬½«Ê¹ÓÃÕâЩÔʼÉèÖÃÀ´·ÖÎöÊÓͼ¡£Òò´Ë£¬·ÃÎÊÊÓͼʱ£¬SET QUOTED_IDENTIFIER ºÍ SET ANSI_NULLS µÄÈκοͻ§¶Ë»á»°ÉèÖö¼²»»áÓ°ÏìÊÓͼ¶¨Òå¡£
×¢Ò⣺
¼æÈݼ¶±ðÉèÖÃÈ·¶¨Êý¾Ý¿âÒýÇæ Êǽ«¿Õ×Ö·û´®½âÊÍΪµ¥¸ö¿Õ¸ñ»¹ÊÇÕæÕýµÄ¿Õ×Ö·û´®¡£Èç¹û¼æÈݼ¶±ðСÓÚ»òµÈÓÚ 65£¬ÔòÊý¾Ý¿âÒýÇæ ½«¿Õ×Ö·û´®½âÊÍΪµ¥¸ö¿Õ¸ñ¡£Èç¹û¼æÈݼ¶±ðµÈÓÚ»ò´óÓÚ 70£¬ÔòÊý¾Ý¿âÒýÇæ ½«¿Õ×Ö·û´®½âÊÍΪ¿Õ×Ö·û´®¡£ÓйØÏêϸÐÅÏ¢£¬Çë²ÎÔÄ sp_dbcmptlevel (Transact-SQL)¡£
¿É¸üÐÂÊÓͼ
Ö»ÒªÂú×ãÏÂÁÐÌõ¼þ£¬¼´¿Éͨ¹ýÊÓͼÐ޸Ļù´¡»
Ïà¹ØÎĵµ£º
ΪÁË´ó¼Ò¸üÈÝÒ×Àí½âÎÒ¾Ù³öµÄSQLÓï¾ä£¬±¾Îļٶ¨ÒѾ½¨Á¢ÁËÒ»¸öѧÉú³É¼¨¹ÜÀíÊý¾Ý¿â£¬È«ÎľùÒÔѧÉú³É¼¨µÄ¹ÜÀíΪÀýÀ´ÃèÊö¡£
¡¡¡¡1.ÔÚ²éѯ½á¹ûÖÐÏÔʾÁÐÃû£º
¡¡¡¡a.ÓÃas¹Ø¼ü×Ö£ºselect name as 'ÐÕÃû' from students order by age
¡¡¡¡b.Ö±½Ó±íʾ£ºselect name 'ÐÕÃû' from students order by age
¡¡¡¡2.¾«È·²éÕÒ:
¡¡ ......
×î½üѧSQL Server2005£¬ÏÂÔØÁËSQL2005ÖÐÎÄ¿ª·¢°æ£¬µ«ÊÇͬѧÃǶ¼°²×°ÉÏÁË£¬Î¨¶ÀÎҵĻúÆ÷°²×°²»ÉÏ¡£
ÿ´Î°²×°DATABASEµÄʱºò¶¼ÌáʾÎÞ·¨Æô¶¯sqlservr.exe·þÎñÎÞ·¨Æô¶¯£¬ÖØװϵͳҲ²»ÐУ¬WINXP WIN 7ÏÂÃ涼ÎÞ·¨°²×°£¬ÓÚÊÇÉÏÍø²éÁËÏ£¬ÔÀ´SQL2005²»Ö§³Ö3ºË´¦ÀíÆ÷£¬Î¢ÈíÒ²×Ô ......
Ò»¡¢Ñ»·
create table tb(
col1 varchar(1),
col2 varchar(2)
)
insert tb(col1,col2)values('0','0')
go 10000000
¶þ¡¢Êý¾ÝºÏ²¢
if object_id('[order]') is not null drop table [order]
go
create table [order]([orderid] int,[ordertype] varchar(1))
insert [ord ......
ÈçºÎʹÓà SSL À´È·±£Óë SQL Server 2000 °²È«Í¨ÐÅ
¸üÐÂÈÕÆÚ£º 2004Äê04ÔÂ20ÈÕ
±¾Ò³ÄÚÈÝ
Ä¿±ê
ÊÊÓ÷¶Î§
ÈçºÎʹÓñ¾ÕÂÄÚÈÝ
ÕªÒª
Äú±ØÐëÁ˽âµÄ±³¾°ÖªÊ¶
°²×°·þÎñÆ÷ÑéÖ¤Ö¤Êé
ÑéÖ¤Ö¤ÊéÊÇ·ñÒÑ°²×°
ÔÚ¿Í»§¶Ë°²×° CA °ä·¢µÄÖ¤Êé
Ç¿ÖÆËùÓпͻ§¶ËʹÓà SSL
ÔÊÐí¿Í»§¶Ë¾ö¶¨ÊÇ·ñʹÓà SSL
Ñé֤ͨÐÅÊÇ·ñÒѼÓÃÜ
ÆäËû× ......
ÔÚÕâÒ»Ò³ÖУ¬ÎÒÃÇÁгöËùÓÐÔÚÕâ¸öÍøÕ¾ÓÐÁгö SQL Ö¸ÁîµÄÓï·¨¡£ÈôÒª¸üÏ꾡µÄ˵Ã÷£¬ÇëµãÑ¡Ö¸ÁîÃû³Æ¡£
ÕâÒ»Ò³µÄÄ¿µÄÊÇÌṩһ¸ö¼ò½àµÄ SQL Óï·¨×öΪ¶ÁÕ߲ο¼Ö®Óá£ÎÒÃǽ¨ÒéÄúÏÖÔھͰ´ Control-D ½«±¾Ò³¼ÓÈëÄúµÄ¡ºÎÒµÄ×î°®¡»¡£
Select
SELECT "À¸Î»" from "±í¸ñÃû"
Distinct
SELECT DISTINCT "À¸Î»"
from "±í¸ñÃû"
Where
......