Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL CREATE VIEWµÄÓ÷¨

ÊÓ¹Û±í (Views) ¿ÉÒÔ±»µ±×÷ÊÇÐéÄâ±í¸ñ¡£Ëü¸ú±í¸ñµÄ²»Í¬ÊÇ£¬±í¸ñÖÐÓÐʵ¼Ê´¢´æ×ÊÁÏ£¬¶øÊÓ¹Û±íÊǽ¨Á¢ÔÚ±í¸ñÖ®ÉϵÄÒ»¸ö¼Ü¹¹£¬Ëü±¾Éí²¢²»Êµ¼Ê´¢´æ×ÊÁÏ¡£
½¨Á¢Ò»¸öÊÓ¹Û±íµÄÓï·¨ÈçÏ£º
CREATE VIEW "VIEW_NAME" AS "SQL Óï¾ä"
"SQL Óï¾ä" ¿ÉÒÔÊÇÈκÎÒ»¸öÎÒÃÇÔÚÕâ¸ö½Ì²ÄÖÐÓÐÌáµ½µÄ SQL¡£
À´¿´Ò»¸öÀý×Ó¡£¼ÙÉèÎÒÃÇÓÐÒÔϵıí¸ñ£º
TABLE Customer
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date date)
ÈôÒªÔÚÕâ¸ö±í¸ñÉϽ¨Á¢Ò»¸ö°üÀ¨ First_Name£¬ Last_Name£¬ ºÍ Country ÕâÈý¸öÀ¸Î»µÄÊÓ¹Û±í£¬ÎÒÃǾʹòÈ룬
CREATE VIEW V_Customer
AS SELECT First_Name, Last_Name, Country
from Customer
ÏÖÔÚ£¬ÎÒÃǾÍÓÐÒ»¸ö½Ð×ö V_Customer µÄÊÓ¹Û±í£º
View V_Customer
(First_Name char(50),
Last_Name char(50),
Country char(25))
ÎÒÃÇÒ²¿ÉÒÔÓÃÊÓ¹Û±íÀ´Á¬½ÓÁ½¸ö±í¸ñ¡£ÔÚÕâ¸öÇé¿öÏ£¬Ê¹ÓÃÕ߾ͿÉÒÔÖ±½ÓÓÉÒ»¸öÊÓ¹Û±íÖÐÕÒ³öËýÒªµÄ×ÊѶ£¬¶ø²»ÐèÒªÓÉÁ½¸ö²»Í¬µÄ±í¸ñÖÐÈ¥×öÒ»´ÎÁ¬½ÓµÄ¶¯×÷¡£¼ÙÉèÓÐÒÔϵÄÁ½¸ö±í¸ñ£º
Store_Information ±í¸ñ
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1999
San Diego
$250
Jan-07-1999
Los Angeles
$300
Jan-08-1999
Boston
$700
Jan-08-1999
Geography ±í¸ñ
region_name
store_name
East
Boston
East
New York
West
Los Angeles
West
San Diego
ÎÒÃǾͿÉÒÔÓÃÒÔϵÄÖ¸ÁîÀ´½¨Ò»¸ö°üÀ¨Ã¿¸öµØÇø (region) ÏúÊÛ¶î (sales) µÄÊÓ¹Û±í£º
CREATE VIEW V_REGION_SALES
AS SELECT A1.region_name REGION, SUM(A2.Sales) SALES
from Geography A1, Store_Information A2
WHERE A1.store_name = A2.store_name
GROUP BY A1.region_name
Õâ¾Í¸øÎÒÃÇÓÐÒ»¸öÃûΪ V_REGION_SALES µÄÊÓ¹Û±í¡£Õâ¸öÊÓ¹Û±í°üº¬²»Í¬µØÇøµÄÏúÊÛŶ¡£Èç¹ûÎÒÃÇÒª´ÓÕâ¸öÊÓ¹Û±íÖлñÈ¡×ÊÁÏ£¬ÎÒÃǾʹòÈ룬
SELECT * from V_REGION_SALES
½á¹û£º
REGION
SALES
East
$700
West
$2050


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

SQL INTERSECTµÄÓ÷¨

ºÍ UNION Ö¸ÁîÀàËÆ£¬ INTERSECT Ò²ÊǶÔÁ½¸ö SQL Óï¾äËù²úÉúµÄ½á¹û×ö´¦ÀíµÄ¡£²»Í¬µÄµØ·½ÊÇ£¬ UNION »ù±¾ÉÏÊÇÒ»¸ö OR (Èç¹ûÕâ¸öÖµ´æÔÚÓÚµÚÒ»¾ä»òÊǵڶþ¾ä£¬Ëü¾Í»á±»Ñ¡³ö)£¬¶ø INTERSECT Ôò±È½ÏÏñ AND ( Õâ¸öÖµÒª´æÔÚÓÚµÚÒ»¾äºÍµÚ¶þ¾ä²Å»á±»Ñ¡³ö)¡£ UNION ÊÇÁª¼¯£¬¶ø INTERSECT Êǽ»¼¯¡£
INTERSECT µÄÓï·¨ÈçÏ£º
[SQLÓï¾ä ......

SQL CONCATENATEµÄÓ÷¨

ÓеÄʱºò£¬ÎÒÃÇÓÐÐèÒª½«Óɲ»Í¬À¸Î»»ñµÃµÄ×ÊÁÏ´®Á¬ÔÚÒ»Æð¡£Ã¿Ò»ÖÖ×ÊÁϿⶼÓÐÌṩ·½·¨À´´ïµ½Õâ¸öÄ¿µÄ£º
MySQL: CONCAT()
Oracle: CONCAT(), ||
SQL Server: +
CONCAT() µÄÓï·¨ÈçÏ£º
CONCAT(×Ö´®1, ×Ö´®2, ×Ö´®3, ...): ½«×Ö´®1¡¢×Ö´®2¡¢×Ö´®3£¬µÈ×Ö´®Á¬ÔÚÒ»Æð¡£Çë×¢Ò⣬OracleµÄCONCAT()Ö»ÔÊÐíÁ½¸ö²ÎÊý£»»»ÑÔÖ®£¬Ò ......

SQL CREATE TABLEµÄÓ÷¨

±í¸ñÊÇÊý¾Ý¿âÖд¢´æ×ÊÁϵĻù±¾¼Ü¹¹¡£ÔÚ¾ø´ó²¿·ÝµÄÇé¿öÏ£¬Êý¾Ý¿â³§É̲»¿ÉÄÜÖªµÀÄúÐèÒªÈçºÎ´¢´æÄúµÄ×ÊÁÏ£¬ËùÒÔͨ³£Äú»áÐèÒª×Ô¼ºÔÚÊý¾Ý¿âÖн¨Á¢±í¸ñ¡£ËäÈ»Ðí¶àÊý¾Ý¿â¹¤¾ß¿ÉÒÔÈÃÄúÔÚ²»ÐèÓõ½ SQL µÄÇé¿öϽ¨Á¢±í¸ñ£¬²»¹ýÓÉÓÚ±í¸ñÊÇÒ»¸ö×î»ù±¾µÄ¼Ü¹¹£¬ÎÒÃǾö¶¨°üÀ¨ CREATE TABLE µÄÓï·¨ÔÚÕâ¸öÍøÕ¾ÖС£
ÔÚÎÒÃÇÌøÈë CREATE TABL ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ