Webã¢ããªã±ã¼ã·ã§ã³éçºã«æ¬ ãããªããã¼ã¿ãã¼ã¹ç®¡çã·ã¹ãã ï¼RDBMSï¼ããªã¼ãã³ã½ã¼ã¹ã®è£½åãåºãå©ç¨ãããæ¨ä»ã§ãããç¡åã§å©ç¨ã§ããåç¨ã®RDBMSãããã¾ãããããªè£½åã®ä¸ã¤ãIBMã®ãDB2ãã§ããæ´å²ãé·ããå®ç¸¾ã¯ããããããã¾ããããã¯ãã£ã¦ã使ã£ããã¨ãªãï¼ ã©ããªããã ã試ãããï¼ ããæã£ãä¸äººããããªã¼ã©ã³ã¹ã®Webã¨ã³ã¸ãã¢å¥³åãid:acotieããã§ãããæ®æ®µããéå¬ãã¦ããåå¼·ä¼ã®çªå¤ç·¨ã¨ãã¦ãåããWebã¨ã³ã¸ãã¢å¥³åã®id:aomushi510ãããå¼ã³ãç¡åã§å©ç¨ã§ãããDB2 Express-Cãã«è§¦ãã¦ã¿ããã¨ã«ãè¨äºã®çµããã«ã¯ãã¬ã¼ã³ãã®ãç¥ãããããã¾ãã
ï¼â»ãã®è¨äºã¯æ¥æ¬ã¢ã¤ã»ãã¼ã»ã¨ã æä¾ã«ããPRè¨äºã§ããï¼
ãã®ãã³ã®æ±æ¥æ¬å¤§éç½ã§è¢«ç½ãããçãã¾ã«å¿ãããè¦èãç³ãä¸ãã¾ããçãã¾ã®å®å ¨ã¨ä¸å»ãæ©ã復æ§ã¨å¾©èãå¿ãããç¥ãç³ãä¸ãã¾ãã
2011å¹´ã®ãããå¹³æ¥ã®å¤ã®ãã¨ã§ãããid:acotieããã¨ãid:aomushi510ããã®äºäººã訪ããã®ã¯ãæ±äº¬é½ä¸å¤®åºæ¥æ¬æ©ç®±å´çºã«ããæ¥æ¬IBMæ¬ç¤¾äºæ¥æãè¿ãã¦ãããã®ã¯ãæ¥æ¬IBMã«ãããDB2ã®ã¹ãã·ã£ãªã¹ããä¸æç´å½¦ããã¨ãä¸ä½ç²æï¼ãããã ãããï¼ããã®ãäºäººã§ããã
æ©éDB2ã®ã話ããã¨æã£ãã¨ãããä¼è°å®¤ã«ã¯ç´ æµãªã³ã¼ãã¼ã«ããã«ãããããã³ã¼ãã¼ãããã«ããããã®ããã¤â¦â¦ãããããªãã¦æ¾èª²å¾ãã£ã¼ã¿ã¤ã !?ãã¨æãã¤ã¤ããacotieããã話ãåãåºãã¾ãã
ããï¼id:acotieï¼ãããã°ãã¯ãä»æ¥ã¯ãæéãããã¨ããããã¾ããDB2ãããããå¦ã¹ãæ©ä¼ãããã ããã¨èãã¦ã楽ãã¿ã«ãã£ã¦ãã¾ããã
ããï¼id:aomushi510ï¼ãæ®æ®µã¯å¥ã®RDBMSã使ã£ã¦ãã¾ãããacotieããã«èªããã¦ãDB2ã«ã©ããªç¹å¾´ãããã®ãå¦ãã§ã¿ããã¨ãã£ã¦ãã¾ãããä»æ¥ã¯èªåã®Macã«DB2ãã¤ã³ã¹ãã¼ã«ãã¦ãã¾ããï¼
ãããç§ãå
¥ãã¦ããã¾ãï¼
ä¸æï¼ãªãï¼ãæ¥æ¬IBMã®ä¸æã§ããããããIBMã¸ããäºäººã¨ããããã¨ããããã¾ããããã¤ã¨ã³ã¼ãã¼ãç¨æãã¦ãå¾
ã¡ãã¦ãã¾ãããã¤ã³ã¹ãã¼ã«ããDB2ã¯è©¦ãã¾ãããï¼
ãããã¯ãããµã³ãã«ã®ãã¼ã¿ãã¼ã¹ãå
¥ãã¦ãEMPãã¼ãã«â¼ã«SELECT *â¼ãã¦ããããã ãã§ããã
ãããç§ãã¡ãã£ã¨åããã¦ã¿ãã ãã§ãã
ä¸ä½ç²ï¼ããï¼ããããååã§ããå®ç§ã ããããããªãããæ¥æ¬IBMã®ä¸ä½ç²ï¼ããããï¼ã¨ç³ãã¾ããDB2ã®ããã°ãæ¸ãã¦ãã¦ããDB2 ããã°ãã§æ¤ç´¢ããã¨ãããã¦ãä¸çªä¸ã«åºã¦ããããã°â¼ã®ä¸ã®äººã§ããä»æ¥ã¯æåã«DB2ã®ç¹å¾´ãç§ããç´¹ä»ããã¦ãã ããã
ââ横ãããã¿ã¾ãããã©ã¤ã¿ã¼ã®éå®®ã§ãããæéããã³ã¼ãã¼ãããã¤ã®ãç¨æãªã©ãããã¨ããããã¾ããã¡ãªã¿ã«ãã®ããã¤ã¯â¦â¦ã
ãªããç§ãã¡ãDB2ã«ã¤ãã¦ç´¹ä»ããã¨ããæå¿ãã¦ããã ããå ´åã«ã¯ãããã¤ããã¬ã¼ã³ããããã¨æãã¾ãã
ããããã£ãããããä¼ç»ã ã£ããã ï¼ç¬ï¼
ââããããããã¨ããããã¾ããacotieãããaomushi510ãããããã¤ã»ããã«ãã¸ã¼ãã£ã¦ããã¨ãããæå¿ããã®ãã©ããã¯ããã¼ãèãã¦ãã ãããï¼ç¬ï¼
ããããªãã»ã©ï¼ç¬ï¼
ãããããã¤æ¬²ããï¼ç¬ï¼
ãããæ¬å½ã«æå¿ãã¦ããã£ã¦ãããã¤ãã渡ããããï¼ DB2ã®èª¬æããã°ãã¾ããããã¤ã³ã¹ãã¼ã«ãã¦ããã ããDB2ãããã®ã§ãæ°ã«å
¥ã£ã¦ããã ããé¨åã¯ãå®éã«è©¦ãã¦ããã ããã¨ãããªã¨æã£ã¦ãã¾ãã
ã¯ã³ãã¤ã³ãç¨èªé
EMPãã¼ãã« - DB2ã®SAMPLEãã¼ã¿ãã¼ã¹ã«ãããã¼ãã«ã®ä¸ã¤ãæ¶ç©ºã®ä¼æ¥ã®å¾æ¥å¡ã®ååãèªçæ¥ã給ä¸ãªã©ãæ ¼ç´ããã¦ããã â²
SELECT * - ãã¼ã¿ãã¼ã¹ããã°ã©ãã³ã°ã§ããå©ç¨ããSQLæã®ä¸ç¨®ãSELECT * FROM [ãã¼ãã«å]ã¨ããåãåããããã¼ã¿ãã¼ã¹ã«å®è¡ããã¨ããã®ãã¼ãã«ãå«ããã¹ã¦ã®ãã¼ã¿ãåå¾ã§ããã â²
ããã¦ãä¸çªä¸ã«åºã¦ããããã° - Unofficial DB2 BLOG â²
â ç¡æçããã28æ³ã®RDBMSããããããªç°å¢ã§åä½
ãããããã§ã¯DB2ã®ç¹å¾´çãªã¨ãããããã¤ã説æããã¨ãããããDB2ã¯1983å¹´çã¾ãã28æ³ã®RDBMSã§ããæ´å²ã¯é·ãã»ãã§ãã
ãªããDB2ã£ã¦ã©ããªã¤ã¡ã¼ã¸ãæã£ã¦ãã¾ããï¼
ãããã¯ãã¼ãºãªã社å
ã·ã¹ãã çãªã¨ããã§ä½¿ããã¦ããã¤ã¡ã¼ã¸ããããããã¾ããåºãã¦ãã¾ãããªæãããã¾ããå¨ãã§ä½¿ã£ã¦ããã£ã¦äººã¯ãæ®å¿µãªãããããã¾ãèãããã¨ãããã¾ããã
ãããããããç¡æã§ä½¿ããã£ã¦ãã¨ãç¥ãã¾ããã§ããã
ãããããããããããªãã§ãããã試ãã¦ã¿ãã¾ã§ãããç¥ããªãã£ãã
ãããã¯ããWebããã°ã©ãã³ã°ã®ä¸çã§ã¯ãæ®å¿µãªããèªç¥åº¦ã¯ãã¾ãé«ããªãã¨æãã¾ããã¾ããç¡æãã®ã¨ããããä¼ããããã§ããDB2ã«ã¯ãDB2 Express-Cãã¨ããç¡æã§ä½¿ããã¨ãã£ã·ã§ã³ãããã¾ãâ¼ãç¡æçã§ãå®ç¨çã§ãããã¼ã¿ãã¼ã¹ã®ãµã¤ãºã¯ç¡å¶éã§ããã使ç¨ç®çãæéã®å¶éãããã¾ãããæ¬çªã§æ®éã«ãå©ç¨ããã ããã±ã¼ã¹ãååããã¨æãã¾ãã
ãããæåçã¨æ¯ã¹ã¦ãä»ã«ä½ãå¶éã¯ãããã§ããï¼
ããã主ãªã¨ããã§ã¯ã¡ã¢ãªã¼2GBãCPU2ã³ã¢ã¾ã§ã¨ããå¶éãããã¾ãããã®ç¯å²ã§æ¸ãããã¸ã§ã¯ãã§ããããå¿«é©ã«ãå©ç¨ããã ããã§ãããã
ãªããDB2ã¯ãããããªç°å¢ã§åããã¨ã売ãã«ãã¦ãã¾ããWindowsããLinuxãAIXãz/OSãAS/400â¦â¦ã
ãããSolarisãHP-UXãªã©ä»ç¤¾ããã®åç¨UNIXã§ãåä½ãã¾ããããããPower Systemsçã®Linuxâ¼ãªãã¦ã®ããMacOSãã§ããã
ãããã¬ã¢ãªãã¼ãã¦ã¨ã¢ã§ãåããã§ããã
ããã対å¿è¨èªãå¤ãã§ããJavaãPHPãRubyãC/C++ãCOBOLãªã©ãªã©ã
ããããµããµãã
ãããä¸çªç¹å¾´çãªã®ã¯ããã¹ã¦ã®è¨èªã§ããã¼ã¿ãã¼ã¹ã«æ¥ç¶ããããã®ãã©ã¤ãããèªç¤¾ã§éçºãã¦ãããã¨ã§ãã
ãããèªç¤¾éçºã§ããï¼
ãããç¥ããªãã£ãï¼
ãããããã£ã¦ãæå¤ã¨ä¾¿å©ãªãã¨ãå¤ãã§ããä¾ãã°Perlã®ãã©ã¤ããå©ç¨ãã¦ããªã«ããã¾ããããªããã¨ããã£ãã¨ããããIBMã®ãµãã¼ãããè³¼å ¥ããã ãã¦ããå ´åã§ããããIBMã«é»è©±ãã¦Perlã®è³ªåãã§ãã¾ãã
ã¯ã³ãã¤ã³ãç¨èªé
DB2 Express-C - DB2ã®ç¡æçãhttp://www.ibm.com/developerworks/jp/offers/db2express-c/ ãããã¦ã³ãã¼ãã§ããã â²
Power Systemsçã®Linux - Power Systemsã¯ããPOWERãCPUãæè¼ããIBMã®UNIXãµã¼ãã¼ã®ã·ãªã¼ãºãOSã¨ãã¦AIXãi5/OSï¼ããããOS/400ï¼ã®ä»ãLinuxãå©ç¨ã§ãããPower Systemsä¸ã§åä½ããLinuxããLinux on POWERãã¨å¼ã³ãIBM DB2ã対å¿ãã¦ããã http://www-06.ibm.com/systems/jp/power/ â²
â èªåã§ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°
ãããåºæ¬çãªã¨ããã¯ãã®ãããã«ãã¦ãDB2ãªãã§ã¯ã®æ©è½ãç´¹ä»ãã¦ããã¾ãããããã¦ãã©ããªRDBMSã§ãããã¼ã¿ãã¼ã¹ãè¨å®ããããã®ãã©ã¡ã¼ã¿ã£ã¦50åã¨ã100åã¨ããããããæ°ãããã¾ãããããããå
¨é¨ãããæãã®å¤ã«è¨å®ããã®ã£ã¦çµæ§ããã©ããããªãã§ããã
ãããã¯ãã
ãããDB2ã«ã¯ãããããèªååããæ©è½ãããã¾ããSelf Turning Memory Managerï¼STMMï¼ã£ã¦ããã¾ãã
ããããµã¼ãã
ããããªããªãè³¢ãã¦ãèªå·±å¦ç¿åãªãã§ããããã¼ã¿ãã¼ã¹ã£ã¦ç¨éããããããããããªãã§ããã決æ¸ã·ã¹ãã 使ãã¨ããã·ã§ããã³ã°ã«ã¼ãã¨ããç¹æ§ã£ã¦ããããéãã¾ããç¹æ§ããããã«ãã£ããã©ã¡ã¼ã¿ãããã¯ãã§ããããã決ããä»çµã¿ãã«ã¼ã«ãã¼ã¹ã§ã¯é£ããã®ã§ãèªå·±å¦ç¿åã«ãã¾ããã
ãããããï¼
ãããå
·ä½çã«ã¯ãDB2ãåãåãSQLããã¼ã£ã¨è¦³å¯ãã¦ãDB2ããã®ãã©ã¡ã¼ã¿ããã£ã¡ã«å¤ãããã©ããªãããªã¼ã£ã¦ã®ã観å¯ãã¦ããããã¦ãããããªãã©ã¡ã¼ã¿ãä¸ä¸ãããªããå¦ç¿ãã¦ããã£ã¦ãã®ã§ãã
ãããããããªããããããâ¦â¦ã
ãªããSTMMãå¤ãå¤ããã¿ã¤ãã³ã°ã¯ãããã©ã«ãã§ã¯3åéã®ãã¼ãªã³ã°ã§ãã3ååä½ã§ã観å¯ãå¤ã®å¤æ´ãå¦ç¿ã®ä¸ã¤ãç¹°ãè¿ãã¾ãã観å¯ããã®ã¯ããã®éã«æµããã¯ã¨ãªã¼â¼ãã¬ã³ã¼ãã®å
容ããã¼ãâ¼ã®ä½¿ãæ¹ãªã©ã§ããããã§ã©ããã½ã¼ããå¤ãããã½ã¼ããã¼ãâ¼ãåºãã¦ã¿ããã¨ãã
ãããããã¼ãï¼
ãããè³¢ãâ¦â¦ï¼æåï¼
ããããï¼ æå¿ãã¦ããã ãã¾ããï¼
ãããï¼ããããï¼ããããããã
ãããä¸ã®ã¯ãªã¼ã ã«ãããããªç¨®é¡ãããããã§ããæãã¦ãªãã¦ã人形ç¼ã¿ããã«éåã§ç¼ããå°ããªãã¼ããã§ããããã¨ãã£ãããã¦ãã¦ãã¯ãã¯ããã¾ãã
ãããï¼ããããï¼ãããã§ã³ã ãããããã
ã¯ã³ãã¤ã³ãç¨èªé
ã¯ã¨ãªã¼ - ã¯ã©ã¤ã¢ã³ããããã¼ã¿ãã¼ã¹ãµã¼ãã¼ã«æ¥ç¶ãã¦ãSQLæãªã©ã§åãåããããããã¨ãã¾ãã¯ãã®åãåãããã®ãã®ã â²
ãã¼ã - æ¢ç´¢ãªã©ã§ç¢ºä¿ããã¡ã¢ãªã¼é åã®ãã¨ããã¼ã¿ã«å¯¾ãã¦ããã¼ãã®å®¹éãå°ãªãããå ´åãå¦çé度ãè½ã¡ãã â²
ã½ã¼ããã¼ã - ã½ã¼ãï¼ä¸¦ã¹æ¿ãï¼ã«ç¨ãããã¼ãã®ãã¨ãâ²
æå¹ããã£ãã¼ãã - ã®ã³ã¶ ãã㣠ã«ã¹ã¿ããããã¥ã¼ã¹ããç´å¾3.5cmã®ç¼ããã¼ããã http://www.petit-custa.com/shop/shop2.html â²
â ã»ã£ããããã§3åã®ããã©ã¼ãã³ã¹ã«
ââããç§ããã¼ããããã ãã¦ãããã§ããâ¦â¦ããã ãã¾ãï¼ããããï¼ããããã ããã¨ããã§èªåãã¥ã¼ãã³ã°ãã©ããªæãã§åãããä¾ãããã°è¦ã¦ã¿ãããã§ããã
ãããï¼ããããâ¦ï¼ãã£ã¨ãããã¯ããOLTPâ¼ç³»ã®ãã³ããã¼ã¯ã®ä¾ãããã¾ãã
ãããSTMMã®å¦ç¿ä¾ãããã§ãã縦軸ããã©ã³ã¶ã¯ã·ã§ã³â¼æ°ã§ãä¸ã®æ¹ãé«æ§è½ã§ããæåãéããã³ããã¼ã¯ãã»ãããã¦ãããã©ã«ãã§1åããã4ä¸5000ã¯ã¨ãªã¼å¦çãã¦ãã¾ãã45åããããã¤ã¨ãå¤ãä¸ä¸ã«æ¯ãå§ãã¾ãã1æéåãããçµã¤ã¨ãã ããã3åå¼±ã®1åããã14ä¸ã¯ã¨ãªã¼ã«ãªãã¾ãã
ãããããã¯ãããï¼
ããã調æ´ãããã¨ããæå¾åæãã¦ãããã§ããã
ãããããã§ãããå®å®ããã¾ã§ããã¿ããã
ãããã¯ããå·¦å´ã®ä¸ã£ã¦ãã1æéåã®é¨åããPhase 1ãã¨èªãã§ãã¾ããã²ããã試ãã¦ã¿ããã§ããã©ãã¨ãã©ãã°ã©ããä¸ã«ä¼¸ã³ã¦ãã¦ãããè¦ãã¨å¤±æãã¦ãããã§ããã
ãããã»ãã¨ã ãä¸ãã£ã¦ãã¨ãããããã
ãããããã§ããã§ã失æããå ´åã¯ããã¹ã£ï¼ãã£ã¦ãã£ã¦ãããæ»ãããããã£ã¦ããã¨ãå¦ç¿ãé²ãã§ãã ããããããªããããªã£ã¦æãã§1æé30åãããã§3åå¼±ãããã®ã¬ãã«ã«ãªãã¾ãããã®å
ãPhase 2ãã£ã¦ãã¤ã«å
¥ã£ã¦ãããã§DB2ã¯åããå¹
ãå°ããããªãããããã§å®å®ãããã©ãããæ¢ã£ã¦ããã¾ãããã®ãã¼ã¿ã ã¨ããªã大ããã®ã§3æéãããããã£ã¦å®å®ãã¦ããã¾ããã¨ããæµãã§ãã
ããããã¼ããããªããããã¯ã
ââå®éã®DB2ã®ã¦ã¼ã¶ã¼ããã§ãSTMMãONã®äººã£ã¦ã©ã®ãããããã£ããããã§ããï¼
ãããæ£ç¢ºã«ã¯ããããªããã§ããã©ããã5ã6å¹´ã®ãã¼ã¸ã§ã³ã§ã¯ããã©ã«ãONã§åºè·ãã¦ãããã§ããããªã®ã§å®éã¯ãç¥ããã«ONã«ãªã£ã¦ããã¨ããã客ããã大åãã¨æãã¾ããããããä¼æ¥æ
å ±ã·ã¹ãã ã§ã¯ãæ¥ä¸ã¨å¤ä¸ã®ãã©ã³ã¶ã¯ã·ã§ã³ã£ã¦ãã¼ã¿ãã¼ã¹ã«æ±ããç¹æ§ãã ãã¶éãã®ã§ãSTMMã«è©³ããã客æ§ã¯ãå¤ä¸ã ãå¦ç¿ãOFFã«ããã¨ãããã¨ããã¦ãã¾ãã
ããããã¼ãªãã»ã©ã¼ãå¤éãããã¯å¦ç¿å¯¾è±¡ã«ããªãã§ãæ¥ä¸ã®ãªã³ã©ã¤ã³ã§ã¬ã¹ãã³ã¹ãéè¦ãªã¨ããã ããå¦ç¿ããã¦ãããã®ããã©ã¼ãã³ã¹ãåªå
ããã£ã¦ãã¨ã§ããã
ãªãããã¹ãã®ã¨ãã«å¦ç¿ãèµ°ããã¦ããã¦ããã¥ã¼ãã³ã°ãçµããç¶æ
ã§ãæ¬çªã§ã¯OFFã«ãã¦ãªãªã¼ã¹ããã¨ãã£ã¦ãã¨ããã¦ãã人ããã¾ãã
ããããµããµããåèã«ãªãã
ãããSTMMã対象ã¨ãã¦ãããã©ã¡ã¼ã¿ã¯20åãããã§ãããããããããã®ã¯7ã8åã§ãã8ã¤ã®ãã©ã¡ã¼ã¿ãå
¨é¨ãã¹ãã®ç¶æ
ã«ããã£ã¦ã人éã§ããã¨1ã¶æ欲ããã£ã¦æãã«ãªã£ã¡ããã¾ãããã
ãããããã§ããã
ãããããã¤ã«ããããã¨ä¸æ©ããã¦ããã°OKã§ãã
ãããã»ã¼â¦â¦ããã®STMMãåããã¨ãã®è² è·ã£ã¦ã©ã®ããããªãã§ããï¼
ãªããã»ã¨ãã©ãªãã§ããCPUã§0.3ãã¼ã»ã³ãã¨ãããããããªã¼ãã¼ã§ãã
ãããã£ã¦ãã¨ã¯ãæ¬çªã§ãµã¼ãã¹ãåãããªãããSTMMãåããã£ã¦ã®ãã§ããã£ã¦ãã¨ã§ããã
ãªããã¯ãã大ä¸å¤«ã§ããã ããããã©ã«ãã§ONã«ãã¦åºè·ãã¦ãã¾ãã
ããããããâ¦â¦ã
ãããããããªãã
ã¯ã³ãã¤ã³ãç¨èªé
OLTP - OnLine Transaction Processingã®ç¥ãã¦ã¼ã¶ã¼ã®è¦æ±ã«ãã¼ã¿ãã¼ã¹ãã¢ããªã±ã¼ã·ã§ã³ãå³åº§ã«çããå¦çã®ãã¨ãâ²
ãã©ã³ã¶ã¯ã·ã§ã³ - åå²ã§ããªãä¸é£ã®æ å ±å¦çã®åä½ãä¾ãã°ãéè¡ã®é éå£åº§ããç¾éãå¼ãåºãã¨ããç¾éãATMã«åºãå¦çã¨ãå£åº§ã®æ®é«ãæ¸ããå¦çã¯åå²ã§ããªãã®ã§ä¸ã¤ã®ãã©ã³ã¶ã¯ã·ã§ã³ãâ²
â XMLãRDBã®ä¸ã«ãã³ãã³ã¨æ¾ãè¾¼ããDB2ã®pureXMLæ©è½
ãããããä¸ã¤DB2ãªãã§ã¯ã®ãè¦ãæ©è½ãããã¾ããXMLâ¼æ©è½ã§ãããpureXMLæ©è½ãã¨å¼ãã§ãã¾ãã
ãªããæ§é åãã¼ã¿ã£ã¦ããä»äºã§ä½¿ããããã¨ã¯ããã¾ããï¼ XMLã使ãã®ããªâ¦â¦ã
ããããã使ãã¾ããXMLãâ¦â¦JSONâ¼ã®ã»ããå¤ãã§ããããYAMLâ¼ãJSONã¨åãããã使ãã¾ãã
ãããXMLã¯æ¸ãã®ãããã©ãã§ããããé¢åãããã¨ãããã
ãããããã§ããããã£ã¤ã表ç¾ã§ãããã§ããã©ããããããæåãå¤ãã¦ãæ¥æ¬èªãå
¥ã£ããã¨ãããããé¢åãããããªã¤ã¡ã¼ã¸ãã©ããã¦ãããã¾ãã
ããããã£ã±ãJSONã¨ããã¬ã¤ã§ããã§ããããããã£ã¨ãDB2ã®pureXMLã®è©±ã§ããããã£ããè¨ã£ã¦ãã¾ãã¨ãXMLã®æ§é åãã¼ã¿ãRDBã§ããDB2ã®ä¸ã«ãã³ãã³ã¨è²¼ãè¾¼ãã¾ããã§ããããé«éã«å¼ãåºãããã§ãããæ°åGãæ°ç¾Gã®XMLã®ãã¼ã¿ããã¼ã³ã¨æ¾ãè¾¼ãã§ã1åã ããã¼ã³ã£ã¦åãåºããã¨ããã®ã売ãã§ãã
ããããããéããã§ãããã©ããªã£ã¦ããã ããã
ãããã¯ãããã®ããæ¹ãã¡ãã£ã¨é¢ç½ãã¦ãããRDBã ã¨ãåã«NUMBERåã¨ããINTEGERåã¨ããåãä»ãã¾ãããã
ãããã¯ãããã¼ãã«ãä½ãã¨ãã«æå®ãã¾ãã
ãããVARCHAR(6)ã¨ãã
ãããããã«ãXMLãã£ã¦æ¸ãããã§ãã
ãããããããXMLåãããï¼ç¬ï¼
ãããããã§ããXMLåã®åã§ãããã®åã«ã½ãã£ã¨XMLãæ¾ãè¾¼ãã¾ãã
ããããã?! ãã®SQLã£ã¦ã©ããããµãã«ãªããã§ããï¼ XMLã®è¦ç´ ãããã®ãã®ãåãåºãã¨ãã
ãããã¯ããããã¤ãããããããããã§ããã©ãXPathâ¼ã£ã¦è¨èªãåãã§ããï¼
ãããã¹ã©ãã·ã¥ã§ã¤ãªããã¢ã¬ã§ãããã
ãããããã§ããSQLã®ä¸ã«XPathæ¸ãããã§ããã
ãããã¸ãããããï¼æå¿ï¼
ãããæè¿ã®DB2ã§ã¯XQueryâ¼ãå
¨é¨è§£éããããã«ãªã£ã¦ã¾ãããªãã§ãXQueryãXPathãæãã¦ããã ãã¨ãã½ãã£ã¨åºãã¾ãã
ãããã¸ãããããï¼ç¬ï¼
ãããSQLæã®ä¸ã«XPathï¼ç¬ï¼ æ°ããï¼ç¬ï¼
ãããWHEREå¥ã«ï¼ç¬ï¼
ãããããã§ããWHEREã®ä¸ã«XPathãæ¸ããããã¾ãã
ããããããããç§ã¯ãã³ã¯ãï¼
ããããããã¯ãã®è¶è²ãã®ã«ããã£ããªã
ãããï¼ããããâ¦ï¼ãããããããªãã
ã¯ã³ãã¤ã³ãç¨èªé
XML - ææ¸ããã¼ã¿ããæ§é ä»ã§è¨è¿°ããããã®ãã¼ã¯ã¢ããè¨èªãç¹å¾´ã¯æ±ç¨çã«å©ç¨ã§ãããã¨ãExtensible Markup Languageã®ç¥ãâ²
JSON - JavaScriptã§æ±ããããã人éã«ãèªã¿æ¸ãããããããã¼ã¿äº¤æã®ããã®ãã©ã¼ããããJavaScript Object Notationã®ç¥ãâ²
YAML - æ§é åãã¼ã¿ãªã©ãæååã¨ãã¦æ±ãããã®ãã¼ã¿å½¢å¼ããªã¹ããããã·ã¥ãªã©ãæ§é ãæ軽ã«è¡¨ç¾ã§ãããâ²
XPath - XMLææ¸ã®ç¹å®é¨åãæã示ãããã®æ§æã®ãã¨ã â²
XQuery - XMLãã¼ã¿ãåãåããããããã®è¨èªã â²
DEAN & DELUCAã®ãã«ãã³ - ãã«ãã³ã¯æ´èåã®ä¸ç¨®ãã¡ã¬ã³ã²ãç ç³ãã¢ã¼ã¢ã³ããã¦ãã¼ãæ··ãåããã¦ããæå½¢ãã¦ç¼ããã¯ãªã¼ã ãã¯ãããDEAN & DELUCAã¯ãé£ã®ã»ã¬ã¯ãã·ã§ããã http://www.deandeluca.co.jp/ â²
â DB2ã«æ ¼ç´ãããXMLã«ã¢ã¯ã»ã¹
ãããï¼ããããâ¦ï¼ãã£ããã§ãããã§ããã©ãXMLãDB2ã«ã©ãå
¥ãã¦ãã©ãæ ¼ç´ããã¦ãã©ãåãåºããã£ã¦ããããæãã¦ããã ãã¾ããï¼
ãããã¯ããã¾ãã¯ã¨ãªã¼ãæããã»ããªãã§ãããããã°ã©ãã³ã°è¨èªãé¸ã°ãªããã§ãããSQLãDB2ã«æããæ©è½ãåãã¦ããããã°ã©ãã³ã°è¨èªããã ã£ãããDB2ã®XMLæ©è½ãå
¨é¨å¼ã³åºãã¾ãã
ããããããããªãã ãã
ããããªã®ã§ããã£ãã¡ãã£ã¨è¨ã£ãããã«ãSQLæã®ä»£ããã«ãXQUERYï½ãã¨æ¸ããããSQLã®WHEREç¯ã«XPathãæ¸ããããã¦ãåãåãããå®è¡ã§ãã¾ãã
ãããXMLãå
¥ããã¨ãã¯â¦
ãããã¯ããæ®éã«INSERTæã§å
¥ãã¾ãã
ããããã£ãï¼ç¬ï¼ ãªãã»ã©ãSQLæã¨çµæã»ããã®é¢ä¿ã¯ãã®ã¾ã¾ãã§ãXQUERYæ¸ããããã¯ã¨ãªã¼ã®çµæãXMLã ã£ãããããã§ããã
ãããXMLãåãåã£ãDB2ã¯ãXMLææ¸ããã¼ã¹ãã¦ãã¨ã©ã¼ãã§ãã¯ãããããã§ãããªã¼æ
å ±ã解æãã¦ããã®ããªã¼æ§é ã®éãã«ãHDDã«ä¿åãã¾ãããªã®ã§ãæ¤ç´¢ãé«éãªãã§ããã
ããããããæ§æãã§ãã¯ãã¦ãããã®ããããããªãã
ãããDB2ã®å®è£
ã¨ãã¦ã¯ãã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ãããããå¥ã«ç¨æãã¦ãã¾ãã
ããããã¼ãã«ã®æ§é ã¨ãã¦ã¯ãRDBã¨ãã¦ã®åã¨ãXMLåã並ãã§ããããã©ããä¿åå
ã¨ãã¦ã¯ãããããå¥ã®ã¨ããã«ä¿åãããã£ã¦ãã¨ã§ããï¼
ãããããã§ããåã¨ãã¦ã¯ä¸ç·ã®ã¨ããã«ä¸¦ãã§ãã¾ãããç©ççã«ã¯å¥ã®ã¨ããã«ä¿åããã¾ããå¤é¨è¨æ¶ä¸ã®æã¡æ¹ã¨ãã¦ã¯ãããããéãæ§é ã«ãªã£ã¦ãã¾ãã
ãããã¨ãã©ã誤解ãããã®ã¯ãDB2ãXMLãæ¡ç¨ããã¨ãã£ã¦ããè¶
é·ãVARCHARã¨ãã¦å
¥ãã¦ãããããªããã£ã¦æããããã¨ãããã¾ãããããã§ã¯ãªãã§ãã
ãããã ããéãåãåºããã£ã¦ãã¨ã§ãããã
ãããã¯ããã¡ãã£ã¨å¤ããã¼ã¿ã§ããã1.5GHzã®CPUã®ãµã¼ãã¼ã§ãXMLãåãåºãã¯ã¨ãªã¼ã®SELECTæã§ã1ç§éã«5000ãã6000ãããå¦çã§ãã¾ãã
ãããã»ã¼ã
ãããXMLã®è¦ç´ ã«ã¤ã³ããã¯ã¹ãå¼µããã¨ãã§ãããã§ããã
ããããã£â¦
ããããã£â¦
ââãªã«ãããããâ¦
ããã詳ããæãã¦ãã ããï¼
ãããããããï¼ ããããï¼
ãããä¾ãã°ãå
¥ç¤¾æ¥æã£ã¦ã¨ã¬ã¡ã³ãããã£ã¦ãããã°ã£ããããåãåºããã¾ãã£ã¦å ´åã¯ãCREATE INDEXæããXMLã«æ¡å¼µããã¦ã¦ã社å¡ã®ã¨ã¬ã¡ã³ãã®ä¸ã®å
¥ç¤¾æ¥æã¨ã¬ã¡ã³ããã£ã¦ã¨ããã«INDEXä½ããªããã£ã¦CREATE INDEXæãä½ãããã§ãããããããã¨ãããã®æ¤ç´¢ãINDEXå¹ãã¦ã¦ãã£ãã£ã¦åãåºããã®ã§ãããéããªãã
ããããµã³ãã«ã³ã¼ãããã¾ããï¼
ããããããªæãã§ããã¤ã³ããã¯ã¹ãä½ãã®ã§æ®éã«create indexï½ã§ãã
create index idx2 on books(bookinfo) generate keys using xmlpattern '/book/price' as sql double;
ãããbooksãã¼ãã«ã®ä¸ã®bookinfoåãgenerate keys usingã£ã¦ãããã¸ãã¾ã§ãã£ããã§ãããã§xmlpatternã£ã¦æ¸ãã¨XPathãæ¸ãããã§â¦â¦ã
ãããã¯ãã¯ãï¼ç¬ï¼
ããããªããèªããï¼ç¬ï¼
ãããããã¼ãï¼ç¬ï¼ ããã¯é¢ç½ãã§ããããXMLã ããXPathã£ã¦ã®ããããèªç¶ãªæµãã§ã
ããããããXPathã£ã¦ã®ã¯æ
£ãã¦ãã人ã«ã¯æ¸ããããã§ããã
ããããããæããããã§ãã
ããããã®ã¤ã³ããã¯ã¹ã¯ãDB2ã®ä¸ã§ã¯ï¼RDBã¨ãã¦ã®ï¼æ®éã®ã¤ã³ããã¯ã¹ã¨åãæ±ããªãã§ãRDBã®ã¤ã³ããã¯ã¹ã使ãæ
£ãã¦ãã人ãªããã¨ãã«æ©ã¾ã使ããã¨æãã¾ããã¿ã¤ãã«ã¿ãããªæååã«ãå¼µãã¾ãããpriceã¿ããªæ°åã«ãå¼µãã¾ãã
ãããããªãç´°ããã«ã¹ã¿ã æ¤ç´¢ã¿ãããªã®ãã§ãããã§ããã
ãããã§ãã¾ããããã使ãããã¨ããã¯indexå¼µã£ã¦ããã¦ãé«éã«è¿ãã
â XMLæ´»ç¨äºä¾
ãããããããã§ãããã ãªããå®éã«ãDB2ã®XMLãå©ç¨ãã¦ããäºä¾ã¯ããã¾ããï¼ ã©ããªXMLãã¼ã¿ãå
¥ãã¦ãããæ°ã«ãªãã¾ãã
ãªãããããã·ã§ããã®äºä¾ãä¸çªããããããã¨æãã¾ããä¾ãã°ã ã©ã¦ãããã¯ã©ãã§ããããå¼ç¤¾ã®äºä¾ãã¼ã¸ãããã¾ãã
ãããã¡ãã£ã¨ãã©ã¦ã¶ã§éãã¦ããã ãã¦ãã¨ããããããRDBã§æ£è¦åãã«ãããã¼ã¿ã£ã¦ãããããªãã§ãããä¾ãã°ãéçã¨ãã½ã³ã³ãé£å¨ã楽å¨ãªãããä¸ç·ã«æ±ããã¨ããã¨ãåã®å®ç¾©ã£ã¦é£ãããªãã¾ãããã
ãããï¼ã ã©ã¦ãããã®ãµã¤ãããã§ãã¯ããªããâ¦ï¼ããããã大å¤ã§ãã
ãããã ã©ã¦ããããããã®ãããåç®ãå¤ããå
å®ããECãµã¤ããªã®ã§ãååã«å
¨é¨é¢é£ããæ
å ±ãRDBã§æ±ããã¨ããã¨å¤§å¤ãªãã¨ã«ãªãã¾ãã
ãããã«ãã´ãªã¨ããããã®ãã¼ã
ãªãããã½ã³ã³ã¨ç
§æå¨å
·ãåããã¼ãã«ã«å
¥ãããã¨ããã¨â¦â¦
ããã大å¤ã ã¼ï¼ç¬ï¼
ãããç¡çç¡çç¡çï¼ç¬ï¼
ãããããããã¨ãã«ãã¼ãã«åãã¦ãã©ããªååã ã£ããã©ãJOINâ¼ãã¦ã¼ã£ã¦ããã ãã¨ãã£ã±ã大å¤ã§ããããããã¨ããã§1æéæ©ããã ã£ãããããããé¢åãªã¨ããã¯ãã¹ã¦XMLã§å¸åãã¦ããããã£ã¦èãæ¹ã§ããååãã¼ãã«ã¯ãJANã³ã¼ãâ¼ã¨ããåååã¨ããå¤æ®µãããã«ãã¦ããã¦ãã»ãã®æ
å ±ã¯å
¨é¨XMLã¨ãã¦XMLåã«ã
ãããã¯ãããï¼æå¿ï¼
ããããµã¼ãï¼æå¿ï¼
ãªããããã製åã®ç¨®é¡ã80ä¸ä»¶ããããã£ãã¨æãã¾ãã
ããã1ã¬ã³ã¼ãããããã«RDBã§æ±ãã«ããååæ
å ±ãXMLã¨ãã¦å
¥ããã¨ããµããµãã
ããããããããããã¨éçºã®é çªãå¤ãããããã§ãããããã¼ã¿ãã¼ã¹ã®ã¹ãã¼ãã決ããããªãã¨éçºã«å
¥ããªãã¨ããã®ãæ®éãªãã§ããã©ãããã®å ´åã¯ãä½ãå§ãã¦å¿
è¦ã«ãªã£ãã¨ããã§ãXMLã®å±æ§ãè¦ç´ ã追å ãããã¨ã§å¯¾å¦ã§ãã¾ãã
ããããã£ãããALTER TABLEâ¼ããªãã¨ã£ã¦é¢åããªãã®ãã
ãããã½ã¼ã¹ã³ã¼ãã¨ãã¼ã¿ãã¼ã¹ã®ã¹ãã¼ãããããªããªãã£ã¦ã±ã¼ã¹ãæ¸ãããã§ããã
ããããããããã¾ããã¼ãããã楽ã§ãããã
ããããããããããããWebãµã¤ãã®ããã¯ã¨ã³ãã§DB2ã使ããã¦ããã¨ãã£ã¦ã®ãããããç¥ããªãã¦ã
ãããç§ãã¯ããã¦ç¥ãã¾ããã
ãããã¡ãã£ã¨ããã¯ãªãã¾ããã
ãããæ´¾æãªæãã¨DB2ã®ã¤ã¡ã¼ã¸ããããªãããããã¾ããããå®ã¯ä½¿ããã¦ãã¾ãã
ã¯ã³ãã¤ã³ãç¨èªé
JOIN - SQLã«ãããã¼ã¿ãã¼ã¹ã¸ã®åãåããã«ããã¦ããã¼ãã«ãçµåããå¦çã®ãã¨ãâ²
JANã³ã¼ã - å ±éåãããPOSã·ã¹ãã ãåçºæ³¨ã·ã¹ãã ã§åºãå©ç¨ããã¦ããååã³ã¼ãã®ãã¨ãååããã±ã¼ã¸ã®ãã¼ã³ã¼ãã«ããæ°åã¨ãã¦è¦ããããJIS X 0501ã¨ãã¦æ¨æºåããã¦ããã â²
ALTER TABLE - RDBMSã«ããã¦ããã¼ãã«ã®åï¼ã«ã©ã ï¼ã追å ããåé¤ãå¤æ´ããã¨ãã«å©ç¨ããSQLæã®ãã¨ã â²
â XMLæ©è½ã®ä½¿ãã©ããã¯ãå ã«æ±ºã¾ããªããã¨ãããã¤ãããããããªãã
ãããDB2ã§ã®ãä¸æãªXMLã®ä½¿ãæ¹ããã£ã¨ç¥ãããã§ãã
ãããåºæ¬çã«ã¯äºã¤ããã¾ããä¸ã¤ã¯ãå
ã«æ±ºã¾ããªããã¨ãããã¿ã¼ã³ã§ãããã¨ãã°å
ã»ã©ã®ååãã¼ãã«ã®ä¾ã ã¨ãæ°è£½åã®ååæ
å ±ãªãã¦æ°ããé
ç®ãå¢ãç¶ãã¾ããããã¦ã¼ã¶ã¼ç®¡çã§ãããã£ã³ãã¼ã³ã®ã¨ãã ã管çé
ç®ã足ããããªãã£ã¦ãã¨ã¯ããã®ã§ã¯ãªããã¨æãã¾ãã
ãããããããï¼ç¬ï¼
ãããããä¸ã¤ã¯ãããã¤ãããããããªããã¨ãããã¿ã¼ã³ã§ããä¾ãã°ç¤¾å¡ãã¼ãã«ãä½ãã¨ãã«é»è©±çªå·ã«ã©ã ãè¤æ°åã£ã¦ããªãã£ã¹ã®é»è©±ãæºå¸¯é»è©±ãèªå®
ã®é»è©±â¦â¦ã£ã¦å
¥ãããã¨ãããã§ããã©ããã¾ã©ãæºå¸¯é»è©±ã®çªå·ãããã¤ãæã£ã¦ãã人ãã¾ãããã
ãããæ大ä½åæã£ã¦ãããããããªãâ¦â¦ã
ãªããããã§RDBã¨ãã¦ãé»è©±çªå·1ãã5ã£ã¦ãã£ã¡ããã¨ã6åç®ãå
¥ããªãã
ããããããã«ã
ãããé»è©±çªå·ãå°ãªã人ã¯ã»ã¨ãã©nullã ããã«ãªãã¾ããã
ãªããããã¨é»è©±çªå·ãã¼ãã«ãå¥ã«ä½ã£ã¦ãidã¨é»è©±çªå·ã§JOINããã£ã¦ãã¨ãããã
ãããã ãã ãé¢åã«ãªãã¾ããã
ããããã¼ã
ãããããããåæ°ãèªããªããã®ãXMLã¨ãã¦æ±ãã£ã¦ããã®ã¯ãããããã§ãã
ãªããããä¸ã¤ããã¨ããã¨ãããªã¼æ§é ã®ãã¼ã¿ã§ãããä¾ãã°æ ç»ã£ã¦ã³ã³ãã³ããæ±ãã¨ããæ ç»ã®å¶ä½æ¥ã¨å
¬éæ¥ãDVDã®çºå£²æ¥ã¨ããã¿ã¤ãã«ã¨é¦é¡ã¨ãããã£ã¹ãã¨ãã®ä»£è¡¨ä½ã¨ããããã¨ãã¾ãã
ãããããããããªã¼æ§é ãRDBã«å
¥ãã¦ãã ããã£ã¦ãäºäººã«ãé¡ãããã¨ãç¡æèã®ãã¡ã«ãããã©ããã£ã¦åã«å解ããããã£ã¦èãå§ãã¡ããã¾ãããã
ãããã¯ãã
ãããããã§ãããã¤ããã¼ãã«ãã§ãã¦ãJOINã§åãåºãã¦ã£ã¦ãã¾ããã§ãXMLã¨ãã¦DB2ã§æ±ãã°ãä½ãèããã«ããªã¼ã®ã¾ã¾æ ¼ç´ã§ãã¾ãã
ãããããã§ããããããã«æ ç»ã®ä¾ã§æ ¼ç´ãã¦ã£ã¦ãããããçºçãããã«ãªãã¨æãã¾ãããã£ã¨ããã¨ãããã足ãã¦ãã¨ãè¨ããããã ï¼ç¬ï¼
ãããããã¼ãï¼ç¬ï¼ ããã¦ã¼ï¼ç¬ï¼
ãããããã¼ã£ï¼ãã£ã¦ãªãï¼ç¬ï¼
ãªãããã¼ã£ï¼ã£ã¦ãªãã¾ãããï¼ç¬ï¼ XMLã®ã¾ã¾æ±ã£ã¦ããã°ãã©ãã©ãä¸ã«é層çã«ãã£ã¤ãã¦ãããã®ã§ããã£ã¤ãããã¯ããã§ãã§ããããã§ãã
ãããç´ æ´ãããï¼ï¼ããããããï¼
ãããï¼ããããããï¼
ãªããææãåºãï¼ ãã«ãã³ãã©ãããäºã¤ä¸ã¤ãããæã£ã¦ãã£ã¦ãã ããï¼ç¬ï¼
ããããããããªãããããä»ã®Webããã°ã©ãã³ã°ã ã¨ãããããé¢åãªãã¼ã¿ã¯ãmemcachedâ¼ãªã©ã«ãJSONã®ãããªæ§é åãã¼ã¿ãæ ¼ç´ãã¦ãããã¨ãå¤ãã¨æãã¾ãã
ãããããã§ããã
ããããªãã»ã©ãã¢ããªå´ã§ããã°ã£ã¦å¦çãã¦ã¾ãããããããã°ã
ããããã¡ããããããã¯ãã£ã¦ãRDBã®ãã¡ã£ã¨ããé¨åãXMLã®ãã¡ãã£ã¨æ±ããé¨åããã®ä¸¡æ¹ãDB2ã ã£ãããã¾ãä¸åæã§æ±ããã¨æãã¾ãã
ãããINSERTããã¨ãã«ï¼XMLã®ï¼æ§æãã§ãã¯ãªããã¯â¦â¦ã
ãããã¯ããã¨ã©ã¼ã¨ãã¦è¿ãã¾ãã
ããã便å©ã¼ï¼ãããããã«ï¼
ãããXMLã¯æ¸ãã®ã¯é¢åã§ãããã©ãã表ç¾ã§ããç¯å²ã¯ãªãããªç¹æ§ãããã¾ããJSONã¨ã®ç¸äºå¤ææ©è½ãããã·ã¼ã¸ã£ã§ç°¡åã«å®ç¾ã§ãã¾ãã
ãªããããããæå³ã§ãæ§é åãã¼ã¿ã®è²¯èµåº«ã¨ãã¦XMLãDB2ã§ããã¾ã使ã£ã¦ããã ããæ©ä¼ã¯çµæ§ãããã§ã¯ãªããã¨ã
ãããããç¥ããªãã£ãã§ããé¢ç½ãã
ã¯ã³ãã¤ã³ãç¨èªé
memcached - ã¡ã¢ãªã¼ã¸ã®ãã£ãã·ã¥ã«ç¹åãããµã¼ãã¼ã½ããã¦ã¨ã¢ãWebã¢ããªã±ã¼ã·ã§ã³ã®å¤§è¦æ¨¡ãªãã¼ã¿å¦çã§ããç¨ããããã â²
â DB2ã®XMLæ©è½ã試ã
ãããã ãã¶XMLæ©è½ã«ãèå³ããã ãããããªã®ã§ãDB2ã®XMLã¾ãããããæå ã®PCã§è©¦ãã¦ããã ãã¾ããããããªããã¡ããã©ãµã³ãã«ãããã¾ããããããäºäººã¨ãMacãªãã§ããã
ãããMacããã§ããMacã
ãããMacæ°ã«ãªããªããDB2ã¯ã¤ã³ã¹ãã¼ã«æ¸ã¿ã§ãããã
ããããããã¯ãï¼
ãªããã§ã¯ãã¼ã¿ãã¼ã¹ãä½ãã¨ããããã
db2 create database xmlsampl using codeset UTF-8 territory JP
ãããDB2ã§ã¯ãã¼ã¿ãã¼ã¹åã¯8æåã¾ã§ãªãã§ãsampleã®eããªãã§ããæåã³ã¼ãã»ããã¯UTF-8ã§ãæ¥æ¬èªã§ãã£ã¦ãã¨ã§ããã
ãããããæ¥ãããcompleted successfulâ¦â¦ã
ãªãããã£ï¼ã¯ãã£ï¼ ãªãã§ãããªéãã®ï¼ï¼
ãããSSDâ¼ã ããããªããéããªãããã£ããè±èªçãªã®ã§ã¡ãã»ã¼ã¸ãè±èªã§ãããã¨ããã§åã®PCã¯ã¾ã ãã£ã¦ã¾ããcreate databaseã£ã¦ãã¼ããã£ã¹ã¯ã¸ã®ã¢ã¯ã»ã¹ãå¤ãã¦ãæéããããã®ãªãã§ããã
ãããæ¥ãæ¥ãã
ãããåã®ã¾ã ã â¦â¦SSDã®Mac欲ãããªãâ¦â¦ããæ¥ããã§ã¯ãã¼ãã«ä½ãã¾ããããã¾ããä»ä½ã£ããã¼ã¿ãã¼ã¹ã«æ¥ç¶ãã¾ãã
db2 connect to xmlsampl
ãªããã¤ãªãã ããã¼ãã«ãä½ãã¾ããSQLã¯ããã§ãããã¡ã¤ã«ä½ã£ã¦ãdb2 -tvf [ãã¡ã¤ã«å]ã§æ¸¡ãã¾ãã
CREATE TABLE xmlitem( id INTEGER NOT NULL PRIMARY KEY, item XML );
ãªãã2åã®ãã¼ãã«ãä½ãã¾ãããINTEGERã§PRIMARY KEYã®idåã¨ãitemã£ã¦ããXMLåã§ãã
ãããããã§ãããã§ããã®ããªâ¦ããªããdescçãªã³ãã³ãã§ãã§ãããã¤ãã¿ãããã§ããã©ãã©ããããããã§ããï¼
ãããç´ æ´ãããããdb2 describe table xmlitemãã¨å
¥åãã¦ãã ããã
ãããï¼ã«ã¿ã«ã¿â¦ï¼ãã¼ãã§ãã¦ã¾ãããããã£ããã
ãããç§ãã§ããã¼ã
ãããåãã¦ã®XMLåï¼
ã¯ã³ãã¤ã³ãç¨èªé
SSD - åå°ä½ã¡ã¢ãªã¼ãå©ç¨ããå¤é¨è¨æ¶è£ ç½®ãSolid State Driveã®ç¥ããã¼ããã£ã¹ã¯ã®ä»£æ¿ã¨ãã¦å©ç¨ãããã¨ãå¤ãããã¼ããã£ã¹ã¯ã¨ããã¹ã¦ãé«ä¾¡ã ããããé«éã«åä½ããã¨ãã«ã©ã³ãã ã¢ã¯ã»ã¹æ§è½ã«åªãããâ²
â ã§ãããã¼ãã«ã«XMLææ¸ãæå ¥ãã
ãªãããµã³ãã«ã®ãã¡ã¤ã«ã«ããµã³ãã«ãã¼ã¿ãä¸æ°ã«èªã¿è¾¼ãload_ddl.txtã¨ããã®ãããã¾ãããããå®è¡ãã¦ãã ããã
db2 -cvf load_ddl.txt
ã§ããã
ãããload_ddl.txtã«ã¯ã©ããªãã¨ãæ¸ãã¦ããã¾ããï¼
ãªããã¯ããLOADã³ãã³ãã§ã
load from load_xml.txt of del XML from xml insert into xmlitem;
ã¨æ¸ãã¦ããã¾ããload_xmlã£ã¦ããã¹ããã¡ã¤ã«ãããã¼ã¿ãè½ã¨ãã¾ããåºåãæåã¯ã«ã³ãã§ããXMLãã¼ã¿ã¯ãXMLãã£ã¦ãã£ã¬ã¯ããªãããã§ãXMLåã«ã¤ã³ãµã¼ãããªããââã£ã¦æå³ã§ããã
ãããload_xml.txtã¯ã©ããªä¸èº«ãªã®ãè¦ã¾ãï¼
ãããã¯ãããããªæãã§ãã
10101,"<XDS FIL='10101.xml' />" 10102,"<XDS FIL='10102.xml' />" 10103,"<XDS FIL='10103.xml' />" 10104,"<XDS FIL='10104.xml' />" 10105,"<XDS FIL='10105.xml' />" 10107,"<XDS FIL='10107.xml' />" â¦â¦
ãããidã¨XMLãã¡ã¤ã«ãæå®ãã¦ããã¾ããXDSã¯ãã®ãã¡ã¤ã«ã®ä¸èº«ãXMLã¨ãã¦ã¼ã¨ããæå³ã§ãã
ãããããå
¥ã£ãããªããdb2 select * from xmlitemãã¨ãå
¥ã£ã¦ãã¼ã
ããããã£ãã¼ã
ãããããã§æºåãã§ãã¾ããã
â XQUERYã§DB2ã«åãåããããã
ãããã§ã¯ãDB2 XQUERYï½ã£ã¦æãã§ã¯ã¨ãªã¼ãæãã¦ã¿ã¾ãããã
XQUERY db2-fn:xmlcolumn('XMLITEM.ITEM')
ãããï¼ã«ã¿ã«ã¿â¦ï¼ãããããããããã358ã¬ã³ã¼ãã
ãããããããã358ã§ããã
ãããã»ãã¨ã 358ã¬ã³ã¼ããåãã¦ã¾ããããããä»åº¦ã¯ã¡ãã£ã¨çµãè¾¼ãã§ã¿ã¾ããããããããã«ãããã£ã¦XPathãã¤ããã ãã§ããµã¤ãºãLã®ååãæ¤ç´¢ã§ãã¾ãã
XQUERY db2-fn:xmlcolumn('XMLITEM.ITEM')/ã¢ã¤ãã [ãµã¤ãº='L']/åå
ããã285件ã§ããã
ãããããã¼ãã£ã¨ãã«ãã³ã®å ´æãééãã¾ããâ¦â¦ãªããã¦ã£ã¨ãã§ãã¼285件ãLãµã¤ãºå¤ãã
ãããSSDã®Macéããªãããããªãâ¦ãæå¾ã«ãselectæã«XPathãæ¸ããå ´åãè¦ã¦ã¿ã¾ãããã
select c.id, c.item from xmlitem c where xmlexists( '$i/ã¢ã¤ãã [åå = "ãã©ã³ã¹é¢¨ã«ã¼ãã£ã¬ã³ï¼ä¸åè¢ï¼"]' passing c.item as "i")
ãªãããã©ã³ã¹é¢¨ã«ã¼ãã£ã¬ã³ï¼ä¸åè¢ï¼ã®ååã ãæãã¦ãããã§ããã
ãããä¸åè¢ã£ã¦ãããªã®ããã®ããªããããã®ã«ãã³ã¯ã©ã£ã¡ã ãå
¨è§ã§ãããï¼ã«ã¿ã«ã¿â¦ï¼
ããããã1ã¬ã³ã¼ããããªãï¼
ãããããã§ããååçªå·20101ã®1åãããªãã§ãã
ãããããã¼åºã20101ã
ããããã£ããã
ãããXPathã®æ®éã®æ§æã§æ¸ãã°ãããã©ã³ã¹é¢¨ã«ã¼ãã£ã¬ã³ããå«ãä¸åè¢ãããªããã¤ãã ã¼ã£ã¨åºãã¾ããã
ããããªãã»ã©ã¼ã
ãªããã¨ããæãã§ãXMLãDB2ã«æ ¼ç´ãã¦ãXQueryãXPathã§åãåããã§ããã¨ãããã¨ãä½é¨ããã ããã¨æãã¾ãã
ãããããããããã¨ããããã¾ããã¼ï¼
â æ®ã£ãããã¤ã®è¡æ¹ã¯â¦â¦
ââé·ãæéãããã¨ããããã¾ãããæå¾ã«acotieããï¼ããï¼ãaomushi510ããï¼ããï¼ããããããææ³ãã¡ãã£ã¨ãã¤æãã¦ãã ããã
ãããããããRDBã£ã¦å¥¥æ·±ãä¸çã§ãããDB2ã奥深ãä¸çããããªã¼ã£ã¦æãã¾ãããããããç¥ããªããã¨ããããããã£ã¦ãä¸æ¹ã§ãèªåãã¥ã¼ãã³ã°ï¼STMMï¼ããXMLæ©è½ãªã©ãDB2ã®éçºè
ããã®æããã¡ããã¨ãã£ã¦ããããæããããã®ã¯æ¥½ããã£ãã§ãã触ã£ã¦ã¿ãã¨ãæã£ã¦ããå°è±¡ã¨å
¨ç¶éã£ã¦ãã¦ã¼ã¶ã¼ãã¬ã³ããªã¼ã§ãããã親ãã¿ãæã¦ã¾ããããããã¨ããããã¾ããã
ãããæ®æ®µã¯Webã¢ããªã±ã¼ã·ã§ã³ãä½ã£ã¦ããã®ã§ãããããã¨ã®è¦ªåæ§ã¿ããã®ã¯ããããã£ããªãã£ã¦æãã¾ãããDB2ã使ã£ã¦ããWebã®äºä¾ãããããã¾ããããXQueryãXPathããSQLã¨çµã¿åããã¦ä½¿ãããã¨ãããã¼ã¿ãã¼ã¹ãã¡ã³ããã³ã¹ãã人ã«åªããã¨ããããWebã¢ããªã±ã¼ã·ã§ã³ã使ã£ã¦ãã人åãã£ã½ãæãããã¾ãããã¨ãã«äººæ°ããããå°ãªãã¨ããªããã¯ãããããç°å¢ã«ããããæ©è½ããããããã£ã¦ã使ã£ã¦ã¿ãããªãã£ã¦æãã¾ããã
ãªããããããããã¨ããããã¾ãã
ãããDB2ã®é
åãä¼ãã£ãããã§ãããããªããæ®ãã®ããã¤ãå
¨é¨ãæã¡å¸°ããã ããï¼
ãããããããããã¨ããããã¾ãï¼
ââä»æ¥ã¯çãã¾ããããã¨ããããã¾ããï¼ ããããèªã¿ã®çãã¾ã«ããã¬ã¼ã³ããããã¾ãã詳ããã¯ããä¸ã«ï¼
â IBMããã«ãã£ã°ããºã¨ããã®è¨äºã§ç»å ´ããDEAN & DELUCAã®ãã«ãã³ããã¬ã¼ã³ã
â»ãã£ã³ãã¼ã³ã¯çµäºãã¾ãããããããã®ãå¿åããããã¨ããããã¾ããã
IBMããã«ãã£ã°ããºï¼LEDã©ã¤ã/æºå¸¯é»è©±å é»æ©è½ä»ã AM/FMã©ã¸ãªãUSBãã¼ã¿ãã«ã¹ãã¬ãªã¹ãã¼ã«ã¼ï¼ãæ½é¸ã§ãã¬ã¼ã³ããã¾ããå¿åæ¹æ³ã¯ããã®è¨äºãã¯ã¦ãªããã¯ãã¼ã¯ã«è¿½å ããã ããããã«ãTwitteré£æºãã¦è¨äºã¸ã®ææ³ããå¯ãããã ããæ¹ã«ã¯ãæ½é¸ã§ãã®è¨äºã§ç»å ´ããDEAN & DELUCAã®ãã«ãã³ããã¬ã¼ã³ãï¼ è©³ããã¯ãä¸ã®å¿åè¦é ãã覧ãã ããã
å¿åè¦é
- å¿åæé
- 2011å¹´5æ23æ¥ï¼æï¼ãã2011å¹´6æ5æ¥ï¼æ¥ï¼24æã¾ã§
- è³åã¨å½é¸äººæ°
- IBMã°ããºã®è©°ãåããã5åæ§ããã®è¨äºã«ç»å ´ããDEAN & DELUCAã®ãã«ãã³ã5åæ§
- å¿åæ¹æ³
- IBMã°ããºã®è©°ãåãã
- ãã®è¨äºãã¯ã¦ãªããã¯ãã¼ã¯ã«è¿½å
- DEAN & DELUCAã®ãã«ãã³
- ããã¯ãã¼ã¯ã³ã¡ã³ãã«ãã®è¨äºã¸ã®ææ³ãæ¸ãã¦ãTwitteré£æºããä¸ã§ãã¯ã¦ãªããã¯ãã¼ã¯ã«è¿½å
- â»ãã©ã¤ãã¼ãã¢ã¼ãã§ãå©ç¨ã®æ¹ã¯å¯¾è±¡ã¨ãªãã¾ãã
- å½é¸çºè¡¨
- å³æ£ãªãæ½é¸ã®çµæãå¾æ¥ã¯ã¦ãªããã¯ãã¼ã¯æ¥è¨ã§ãå½é¸è æ§ãçºè¡¨ããã¦ããã ãã¾ã
- è³åçºé
- å½é¸çºè¡¨å¾ãã¯ã¦ãªããã¡ã¼ã«ããéãããéä»å æ å ±ï¼éä»å ä½æãåå人æ°åãé»è©±çªå·ï¼ããèããã¾ã
åçï¼ä½è¤éº»ç´