MS Management Studio 2005ã®ãªãªãŒã¹ã§ãç¶æ³ã¯å€ãããŸããã§ããã ãããŠãMS Management 2008ã§ã®ã¿Transact-SQL IntelliSenseãç»å ŽããŸããã ã¯ããå ¥åãããåèªã®èªåè£å®ãããŒã¿ããŒã¹ãªããžã§ã¯ããšããŒãã«ãã£ãŒã«ãã®ãªã¹ããæ§æã®åŒ·èª¿è¡šç€ºïŒbegin ... endãïŒïŒïŒããããŸããã ããããã®åã«ãSoftTree Technologiesã®ãµãŒãããŒãã£è£œSQL AssistantãŠãŒãã£ãªãã£ã䜿ãå§ããŸããã SQL AssistantãæäŸããæ©äŒã®äžã§ããã€ãã£ãIntelliSenseã¯ãŸãã«ãªãŒã¯ã§ãã ããããããã¯SQLã§ããããªããžã§ã¯ãæåèšèªã§ã¯ãªããããããã«äœããååŸããããšã¯å¯èœã§ããããïŒ ã§ããŸãïŒ ãã®èšäºã§ã¯ãSQL AssistantãŠãŒãã£ãªãã£ãç¹ã«SQLã³ãŒããäœæãããšãã«äœ¿çšããé¢æ°ãšææ³ã«ã€ããŠèª¬æããŸãã
çè«
SQL Assistantã¯ãéçºè ããã³ããŒã¿ããŒã¹ç®¡çè åãã®ããŒã«ãããã§ãã å°ããªããŒã¿ããŒã¹ããè€éãªäŒæ¥ã·ã¹ãã ãŸã§ãããããè€é床ã®ãããžã§ã¯ãã§äœæ¥ãããšãã«äœ¿çšã§ããŸãã ãã®ãœãããŠã§ã¢ã¯ãã€ã³ã¹ããŒã«åŸããã«äœ¿çšã§ããç¶æ ã§ãããçŸåšã®äœæ¥ããã»ã¹ã®äžæã¯å«ãŸããŸããã ãã®ããŒã«ãããã¯ãSQLéçºè ã®çç£æ§ãåäžãããé«å質ã®ã³ãŒããä¿èšŒããŸãã ããã±ãŒãžãå«ãããšãSQLæ§æã®æ£ç¢ºæ§ãæ§ææ§é ã®èªåè£å®ãããã°ã©ã ã³ãŒãå ã®è¿ éãªããã²ãŒã·ã§ã³ãªã©ã確èªããããã®åªããããŒã«ãå«ãŸããŸãã ãŸãããŠãŒã¶ãŒã¯çµ±åãããã¹ãã«ãã§ãã«ãŒãèŠã€ããã§ãããã ãã®è£œåã®ãã®ä»ã®å©ç¹ã®äžã§ããæãäžè¬çãªDBMSïŒOracleãSQL ServerãDB2ãMySQLãSybase ASEãSybase ASAãMS Accessãããã³å¯Ÿå¿ããSQLæ¹èšïŒã®ãµããŒãã«èšåãã䟡å€ããããŸãã
SQL Assistantã¯Management Studioã«çµã¿èŸŒãŸããŠããããã®ãã¹ãŠã®ã³ãã³ãã¯ãã¡ã€ã³ã¡ãã¥ãŒé ç®ãŸãã¯ã³ãŒããšãã£ã¿ãŒã®ã³ã³ããã¹ãã¡ãã¥ãŒãã䜿çšã§ããŸãã
äž»ãªæ©èœã¯æ¬¡ã®ãšããã§ãã
- ã³ãŒãå ¥åã¢ã·ã¹ã¿ã³ã
- ã³ãŒãããã²ãŒã·ã§ã³ïŒã³ãŒãæ§é ãããã¥ã¡ã³ããããïŒ
- ã³ãŒãã®ãã©ãŒããã
- ãã¿ãŒã³ãšã³ãŒããžã§ãã¬ãŒã¿ãŒ
- ãªãã¡ã¯ã¿ãªã³ã°é¢æ°
- SQLã³ã³ã¹ãã©ã¯ããå ¥åããããã®å¯Ÿè©±åãã«ãã·ã¹ãã
- ãªããžã§ã¯ãã¹ã¯ãªããã®ååŸïŒããŒãã«äœæã¹ã¯ãªãããããã·ãŒãžã£ãé¢æ°ãªã©ïŒ
- ã¯ã€ãã¯ãã¥ãŒããŒãã«
- ããŒã¿ã®ã¹ã¯ãªããäœæãã€ã³ããŒãããšã¯ã¹ããŒã
- åå¥ã®SQLå®è¡
- SQLå®è¡ã¹ã±ãžã¥ãŒã©ïŒWindowsã¹ã±ãžã¥ãŒã©ã䜿çšïŒ
- ãã¹ãããŒã¿ãžã§ãã¬ãŒã¿ãŒ
- åäœãã¹ããã¬ãŒã ã¯ãŒã¯
- ããã¯ã°ã©ãŠã³ãæ§æãã§ãã¯
- ã¯ãšãªããã©ãŒãã³ã¹ã¢ãã©ã€ã¶ãŒ
- ããŒãžã§ã³ç®¡çã·ã¹ãã ãšã®çµ±å
- ã¹ãã«ãã§ãã¯
- ã³ãŒãæ¯èŒ
- ããã
åºæ¬æ å ±ã¯ãå ¬åŒWebãµã€ãããã³ããã¥ã¡ã³ãïŒèšäºã®æåŸã«ãããªã³ã¯ïŒã«ãããŸãã ãããŠããã®ãŠãŒãã£ãªãã£ã®æãéèŠãªæ©èœã§ããã¢ã·ã¹ã¿ã³ãèªäœã«ã€ããŠã話ããŸããã³ãŒããšãã£ã¿ã«è¡šç€ºãããã³ã³ããã¹ãäŸåã®ãããã¢ãããŠã£ã³ããŠã§ãã
ç·Žç¿ãã
ã¢ã·ã¹ã¿ã³ãã¯ãå ¥åãããåèªãèªåçã«è£å®ããããã®ãã³ãããå§ãŸããããŒãã«éã®ãªã³ã¯ã®æ§ç¯ã§çµãããåŒã³åºãããå Žæã«å¿ããŠæ¯æŽãæäŸããŸãã ããã€ãã®ããŒãã«ãå«ãã¯ãšãªãäœæããã®ã«ãããæéã¯ã¯ããã«çããªããŸãã ããŒãã«ãšãã£ãŒã«ãã®ååãééããããšã¯ãããããŸãããé¢ä¿ãæ§ç¯ããããã«äž»ããŒãã£ãŒã«ããšå€éšããŒãã£ãŒã«ããèŠããŠããå¿ èŠã¯ãããŸããã ãªã¹ãããããŒãã«ã®ååãæå®ããã ãã§ãSQL Assitantèªäœããéžæããå€éšãââãŒã«åºã¥ããŠçµåæ§é ãçµäºããŸãã
fromã»ã¯ã·ã§ã³ãããªã¯ãšã¹ããæžãå§ããŸãã æåã®ããŒãã«ã®ååã瀺ãããå éšçµåãå ¥åãããšããŠã£ã³ããŠã®ã¢ã·ã¹ã¿ã³ãã«ãProductããŒãã«ã®å€éšããŒãååšããããŒãã«ã®ãªã¹ãã衚瀺ãããŸãã èµ€ã§åŒ·èª¿è¡šç€ºããããã£ãŒã«ãã¯ã2ã€ã®ããŒãã«ãçµåããããã«äœ¿çšãããŸãã ProductInventoryããŒãã«ãžã®æ¥ç¶ãéžæããã³ãŒããååŸããŸãã
éžæ
ãã
çç£ã 補å p
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã ProductInventory pi1 ON pi1ã ProductID = pã ãããã¯ãID
次ã«ãã¯ãšãªã®äœæãç¶ããå éšçµåãå ¥åãããšãã¢ã·ã¹ã¿ã³ãã¯ProductInventoryããŒãã«ã®å€éšããŒãæ¢ã«ååšããããŒãã«ã®ãªã¹ãã衚瀺ããŸãããProductããŒãã«ããã®æ¥ç¶ãå©çšã§ããŸãã
ãªã³ã¯æ§ç¯ã¯ãfromã»ã¯ã·ã§ã³ã§æ©èœããŸãã ãããŠãéžæãæ¿å ¥ãåé€ãæŽæ°ã®ããã«ã å€éšããŒã§æ¥ç¶ãããŠããªãããŒãã«éã®æ¥ç¶ãæ§ç¯ããå¿ èŠãããå Žåããããã®ããŒãã«ãæå®ããå¿ èŠããããŸããSQLAssistantã¯åãååã®ãã£ãŒã«ãã§ãªã¬ãŒã·ã§ã³ã·ãããæ§ç¯ããããšãææ¡ããå ŽåããããŸãã
åä¿¡ãããªã¯ãšã¹ãã³ãŒãïŒ
éžæ
ãã
çç£ã 補å p
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã ProductInventory pi1 ON pi1ã ProductID = pã ãããã¯ãID
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã å Žæ l ON lã LocationID = pi1ã ãã±ãŒã·ã§ã³ID
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã ProductReview pr ON prã ProductID = pã ãããã¯ãID
formaté¢æ°ã䜿çšããŠãç®çã®ãã©ãŒã ã«ç§»åããŸãã ã³ãŒãã®ãã©ãŒãããèŠåã¯ã«ã¹ã¿ãã€ãºå¯èœã§ãã
éžæ
ãã
çç£ã 補å p
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã ProductInventory pi1
ãªã³
pi1ã ProductID = pã ãããã¯ãID
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã å Žæ l
ãªã³
lã LocationID = pi1ã ãã±ãŒã·ã§ã³ID
ã€ã³ããŒã¯ãããã¯ã·ã§ã³ã«åå ããŸãã ProductReview pr
ãªã³
prã ProductID = pã ãããã¯ãID
éžæã»ã¯ã·ã§ã³ã«ã«ãŒãœã«ã移åãããšãã¢ã·ã¹ã¿ã³ãã¯ãfromã»ã¯ã·ã§ã³ã«ãªã¹ããããããŒãã«ããéžæã«å«ãŸãããã£ãŒã«ããéžæããããã®ãã³ãã衚瀺ããŸãã ãªã¯ãšã¹ãã®ã©ã®ã»ã¯ã·ã§ã³ã§ãåãååïŒå Žæãã°ã«ãŒãåãé åºä»ãïŒã
ãã£ãŒã«ãã®ã¿ã€ãã«é¢ããæ å ±ã«å ããŠãäž»ããŒãæ§æãããã£ãŒã«ãã«ã¯ãé»è²ã®ããŒãç·è²ã®ããŒ-å€éšããŒã®ãã£ãŒã«ãã皲劻-ã®åœ¢ã§ã¢ã€ã³ã³ã衚瀺ãããŸãã
ä»ã®ãµãŒããŒããŒã¿ããŒã¹ã®çŸåšã®ããŒã¿ããŒã¹ã«ããä»ã®ãªããžã§ã¯ãããªã¹ãã«ãããŸãã fromã»ã¯ã·ã§ã³ã«ãªãããŒãã«ãããã£ãŒã«ããéžæãããšããã®ãã£ãŒã«ãã¯èªåçã«fromã»ã¯ã·ã§ã³ã«è¿œå ãããŸãã éä¿¡ã«å¿ èŠãªæ¡ä»¶ãè¿œå ããã ãã§ãã
äžè¬ã«ã次ã®ãªããžã§ã¯ããšãã®ã³ã³ããŒãã³ãããªã¹ãã«è¡šç€ºã§ããŸãã
- ããŒã«ã«å€æ°
- äžæããŒãã«
- æ°žç¶çãªããŒãã«
- æåº;
- æé ;
- æ©èœ
- å矩èª;
- ã¹ããŒã
- ããŒã¿ããŒã¹
- çµã¿èŸŒã¿é¢æ°ã
ããã¯ãã¹ãŠãã¢ã·ã¹ã¿ã³ãã³ãŒã«ã®ã³ã³ããã¹ãã«äŸåããŸãã ãããã£ãŠãinsert Production.Productã³ã³ã¹ãã©ã¯ããèšè¿°ããå Žåããã«ããŒãåŒã³åºããšãinsertã¹ããŒãã¡ã³ããæžã蟌ãŸããããŒãã«ã®å¿ é ãã£ãŒã«ããéžæã§ããŸãã
ãã ãããªãã¬ãŒã¿ãŒèªèº«ã®äœææã«ã¢ã·ã¹ã¿ã³ãã䜿çšããæ¹ã䟿å©ã§ãã insertã¹ããŒãã¡ã³ããæžããåŸãã¢ã·ã¹ã¿ã³ãã¯ããŒã¿ããŒã¹ãªããžã§ã¯ããéžæããããã«ä¿ããŸãã
å¿ èŠãªããŒãã«ãéžæãããšã次ã®ã³ãŒããèªåçã«åãåããŸãã
ãããã¯ã·ã§ã³ã«æ¿å ¥ããŸãã å Žæ
ïŒ
-LocationID-ãã®åã®å€ã¯èªåçæãããŸã
ãåå
CostRate
åšåº«ç¶æ³
ModifiedDate
ïŒ
䟡å€
ïŒ
/ * {åå} * / ã
/ * {CostRate} * / /
/ * {å¯çšæ§} * / ã
/ * {ModifiedDate} * /
ïŒ
æŽæ°æŒç®åã§ãåæ§ã«ååŸãããŸãã ã³ãŒãã¯åæ§ã®å ¥åã·ãŒã±ã³ã¹ã§èªåçã«çæãããŸãïŒ
çç£ãæŽæ°ããŸãã å Žæ
ã»ãã
-LocationID =ïŒ -ãã®åã®å€ã¯èªåçæãããŸã
åå= ïŒã
CostRate = ïŒã
å¯çšæ§= ïŒã
ModifiedDate = ïŒ
ããŒãã«æ§é ã«åºã¥ããŠå€æ°ã宣èšããããšãã§ããŸãã declareãšå ¥åããŠLocationããŒãã«ãéžæãããšãçµæãšããŠã³ãŒããçæãããŸãã
ãã«ãŒã«
@LocationID SMALLINT ã
@Name nameã
@CostRate SMALLMONEY ã
@Availability DECIMAL ïŒ 8ã2 ïŒ ã
@ModifiedDate DATETIME
ããã·ãŒãžã£ãŸãã¯é¢æ°ã®åŒã³åºããäœæããŸãã
ã³ãŒãã§äœæãŸãã¯å®£èšããããªããžã§ã¯ãã§ãããã¢ã·ã¹ã¿ã³ããŠã£ã³ããŠã§äœ¿çšå¯èœã«ãªããŸãã äžæããŒãã«ã®äœæãããŒãã«ã®ããŒãã«ãå«ãå€æ°ã®å®£èšãèæ ®ããŸãã
ã³ãŒãã§å€æ°ã«åºäŒããCtrlããŒãæŒããªãããã®å€æ°ãã¯ãªãã¯ãããšããã®å€æ°ã宣èšãããå Žæã«ç§»åããŸãã ãã ããã«ãŒãœã«ããã®å€æ°ã«ç§»åãããšãå€æ°ã®ã¿ã€ãã瀺ãããŒã«ããããååŸããæ¹ãç°¡åã§ãã ããŒãã«ã®å Žåãäœæããã¹ã¯ãªããã®æ§é ãšãªã³ã¯ãã³ã³ãã³ãã®ã¯ã€ãã¯ãã¥ãŒãããã³è©³çŽ°æ å ±ã衚瀺ãããŸãã ã·ã¹ãã
æé ã«ã€ããŠ-ãã©ã¡ãŒã¿ã®ãªã¹ããªã© ä»ã®ãªããžã§ã¯ãçšã
çµã¿èŸŒã¿é¢æ°ã®å Žåãé¢æ°ã®ç°¡åãªèª¬æãå«ãããŒã«ãããã ãŸããã¢ã·ã¹ã¿ã³ãã¯ãã©ã¡ãŒã¿ã®å ¥åãæ¯æŽããŸãã
ãããã«
Management Studioã§ã®äœæ¥äžã«æ¯æ¥äœ¿çšããäž»ãªæ©èœã¯æ¬¡ã®ãšããã§ãã ãããã¯ãSQL Assistantã®ãã¹ãŠã®æ©èœãšã¯ã»ã©é ããã®ã§ãã ããã«å€ãã®èå³æ·±ãæ©èœãæ©èœã楜ãããã®ããããŸãã ãããããªã³ã¯ãããŒãã«ããã³ããŒãã«ãã£ãŒã«ããéžæããããã®ã³ã³ããã¹ããªã¹ããäœæããããšã§ãããã°ã©ãã®äœæ¥ãå€§å¹ ã«è»œæžã§ãããšæããŸãã ãšããã§ãSQL Assistantã¯ããŠãŒã¶ãŒãå ¥åããæåæ°ãšã¢ã·ã¹ã¿ã³ããè¿œå ããæåæ°ã«é¢ããçµ±èšãä¿æãããã®ããŒã¿ããçç£æ§ã®äŒžã³ã®å²åãèšç®ããŸãã
åç §è³æ
å ¬åŒãµã€ãSQL Assistant
ããã¥ã¡ã³ãïŒPDFã7.2MbïŒ