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

SQL Server 2005ÖеÄT SQLÔöÇ¿D

µÝ¹éµÄͨÓñí±í´ïʽ
µÝ¹éµÄCTEÊǸù¾ÝÖÁÉÙÁ½¸ö²éѯ£¨»òÕß³ÆÎªÁ½¸ö³ÉÔ±£©¹¹½¨µÄ£¬Ò»¸öÊǷǵݹé²éѯ£¬Ò²³ÉΪ¹Ì¶¨³ÉÔ±£¬Ö»Äܵ÷ÓÃÒ»´Î£¬ÁíÍâÒ»¸öÊǵݹé²éѯ£¬Ò²³ÉΪµÝ¹é³ÉÔ±£¨RM£©£¬¿ÉÒÔ·´¸´µ÷Óã¬Ö±µ½²éѯ²»ÔÙ·µ»ØÐС£²éѯÓÉUNION ALLÔËËã·ûÁ¬½ÓΪһ¸öµ¥¶ÀµÄCTE¡£
--ʹÓõݹéµÄͨÓñí±í´ïʽ
GO
CREATE TABLE CarParts
(
CarID INT NOT NULL,
Part VARCHAR(15),
SubPart VARCHAR(15),
Qty INT
)
GO
INSERT CarParts VALUES (1, 'Body', 'Door', 4)
INSERT CarParts VALUES (1, 'Body', 'Trunk Lid', 1)
INSERT CarParts VALUES (1, 'Body', 'Car Hood', 1)
INSERT CarParts VALUES (1, 'Door', 'Handle', 1)
INSERT CarParts VALUES (1, 'Door', 'Lock', 1)
INSERT CarParts VALUES (1, 'Door', 'Window', 1)
INSERT CarParts VALUES (1, 'Body', 'Rivets', 1000)
INSERT CarParts VALUES (1, 'Door', 'Rivets', 100)
INSERT CarParts VALUES (1, 'Door', 'Mirror', 1)
GO
SELECT * from CarParts
GO
WITH CarPartsCTE(SubPart, Qty)
AS
(
-- ¹Ì¶¨³ÉÔ± (AM):
-- SELECT²éѯÎÞÐè²Î¿¼CarPartsCTE
SELECT SubPart, Qty
from CarParts
WHERE Part = 'Body'
UNION ALL
-- µÝ¹é³ÉÔ± (RM):
-- SELECT²éѯ²Î¿¼CarPartsCTE
SELECT CarParts.SubPart, CarPartsCTE.Qty * CarParts.Qty
from CarPartsCTE
INNER JOIN CarParts ON CarPartsCTE.SubPart = CarParts.Part
WHERE CarParts.CarID = 1
)
-- Íⲿ²éѯ
SELECT SubPart, SUM(Qty) AS TotalNUM
from CarPartsCTE
GROUP BY SubPart


Ïà¹ØÎĵµ£º

SQLÈý´ó·¶Ê¾

µÚÒ»·¶Ê½:È·±£Ã¿ÁеÄÔ­×ÓÐÔ.
Èç¹ûÿÁÐ(»òÕßÿ¸öÊôÐÔ)¶¼ÊDz»¿ÉÔÙ·ÖµÄ×îСÊý¾Ýµ¥Ôª(Ò²³ÆÎª×îСµÄÔ­×Óµ¥Ôª),ÔòÂú×ãµÚÒ»·¶Ê½.
ÀýÈç:¹Ë¿Í±í(ÐÕÃû¡¢±àºÅ¡¢µØÖ·¡¢……)ÆäÖÐ"µØÖ·"Áл¹¿ÉÒÔϸ·ÖΪ¹ú¼Ò¡¢Ê¡¡¢ÊС¢ÇøµÈ¡£
µÚ¶þ·¶Ê½:ÔÚµÚÒ»·¶Ê½µÄ»ù´¡Éϸü½øÒ»²ã,Ä¿±êÊÇÈ·±£±íÖеÄÿÁж¼ºÍÖ÷¼üÏà¹Ø.
Èç¹ûÒ»¸ö¹ØÏµÂú×ã ......

SQL³£ÓÃÓï¾ä


SQL³£ÓÃÓï¾ä
SQLÓï¾äÏÈǰдµÄʱºò£¬ºÜÈÝÒ×°ÑÒ»Ð©ÌØÊâµÄÓ÷¨Íü¼Ç£¬ÎÒÌØ´ËÕûÀíÁËÒ»ÏÂSQLÓï¾ä²Ù×÷¡£
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk ......

PL/SQLÁ¬½ÓOracle(Ãâ°²×°oracle¿Í»§¶Ë)

 
      ´ó¼Ò¶¼ÖªµÀ£¬ÓÃPL/SQLÁ¬½ÓOracle£¬ÊÇÐèÒª°²×°Oracle¿Í»§¶ËÈí¼þµÄ¡£ÓÐûҪÏë¹ý²»°²×°Oracle¿Í»§¶ËÖ±½ÓÁ¬½ÓOracleÄØ£¿
      ÆäʵÎÒÒ»Ö±ÏëÕâÑù×ö£¬ÒòΪÕâ¸ö¿Í»§¶ËʵÔÚÌ«ÈÃÈËÌÖÑáÁË£¡£¡£¡²»µ«»á°²×°Ò»¸öJDK£¬¶øÇÒ»¹»á°Ñ×Ô¼º·ÅÔÚ»·¾³±äÁ¿µÄ×îÇ°Ãæ£¬»áÔì³É²»Ð ......

little notesÖ®SHARED_POOL SQL½âÎö

TOM´óÊåµÄµ÷ÓÅÊéÖÐ˵¹ýÒ»¾ä»°£¬¾ßÌåÓ¢ÎľÍÍüÁË£¬´ó¸ÅÒâ˼¾ÍÊÇ£ºÈç¹ûÓÐÈËÈÃÎÒд±¾ÔõÑùÈÃORACLEÐÔÄÜ×îÂýµÄÊéµÄ»°ÎһὫȡÏû°ó¶¨±äÁ¿(bind variable)×öΪÊéµÄµÚÒ»ÕºÍ×îºóÒ»ÕÂ(ËûµÄÒâ˼ÊÇËûºÜÓÐÓÄĬ~~!)£¬¿É¼û°ó¶¨±äÁ¿µÄÖØÒªÐÔ¡£
°ó¶¨±äÁ¿´ó¶àÓÃÔÚOLTP(online transaction process)ÖУ¬ÔÚOLAP(online analizy process)ÖоÍû± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ