DBÀ߷פǹԤ¦¤³¤È

  1. DBÀ߷פÎɸ½à²½
    1. ¥Ç¡¼¥¿¹àÌÜ¡§¥«¥é¥à̾¡¦·¿
    2. ¥Ç¡¼¥¿À°¹çÀ­¡§ÈÏ°Ï¡¦°ì°ÕÀ©Ìó¡¦Èó¥Ì¥ë¡¦»²¾ÈÀ©Ìó
    3. ¥³¡¼¥ÉÂηÏ
  2. DBÀ߷פϥ쥤¥ä¤´¤È¤ËÃê¾ÝÅ٤ΰ㤦ºî¶È¤ò¹Ô¤¦
    ¥â¥Ç¥ë¤Ç¤¤¤¦¤È¥¹¥­¡¼¥Þ¤Ç¤¤¤¦¤È¶ñÂÎÎã¡¢À®²Ìʪ
    (¥×¥í¥°¥é¥à)(DBÀ߷פ«¤é¸«¤ë¤È)¥æ¡¼¥¶¥¤¥ó¥¿¥Õ¥§¡¼¥¹
    ³°Éô¥¹¥­¡¼¥ÞSQL¥Ó¥å¡¼¡£ÏÀÍý¥Ç¡¼¥¿ÆÈΩÀ­
    ³µÇ°¥Ç¡¼¥¿¥â¥Ç¥ë³µÇ°¥¹¥­¡¼¥ÞER¿Þ¡£¶È̳»ÅÍÍ
    ÏÀÍý¥Ç¡¼¥¿¥â¥Ç¥ëÆâÉô¥¹¥­¡¼¥Þ¥Æ¡¼¥Ö¥ëÄêµÁµÁ¡£ÊªÍý¥Ç¡¼¥¿ÆÈΩÀ­
    ʪÍý¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯ÊªÍýÀß·×

³µÇ°¥Ç¡¼¥¿¥â¥Ç¥ë

  1. ³ÈÄ¥ER¿Þ(ÏÀÍý¥Ç¡¼¥¿¥â¥Ç¥ë¤âER¿Þ¤Çɽ¤¹¤³¤È¤¬¤Ç¤­¤ë)
  2. Entity¤ÎRelationship(´ØÏ¢)¤òɽ¤·¤¿¤â¤Î
           Ž¶Ž°ŽÃŽÞŽ¨ŽÅŽØŽÃŽ¨(¿½ÅÅÙ)
          1    n      n      n
    [¸ÜµÒ]----->[¼õÃí]<----->[¾¦ÉÊ]
    Ž´ŽÝŽÃŽ¨ŽÃŽ¨       ´ØÏ¢        Ž´ŽÝŽÃŽ¨ŽÃŽ¨
  3. Ï¢´Ø = n:n¤Î´ØÏ¢¤ò¤µ¤±¤ë°Ù¤ËÊص¹Åª¤Ëºî¤é¤ì¤ë¥¨¥ó¥Æ¥£¥Æ¥£
          1    n      1    n          n   1
    [¸ÜµÒ]----->[¼õÃí]----->[¼õÃíÌÀºÙ]<----[¾¦ÉÊ]
  4. ÈƲ½(·Ñ¾µ)
       ²ñ°÷     ¥¹¡¼¥Ñ¡¼¥¿¥¤¥×
        ¡Ã
      ¡²¢¤¡²
     ¡Ã    ¡Ã
    Ë¡¿Í  ¸Ä¿Í  ¥µ¥Ö¥¿¥¤¥×
    ²ñ°÷  ²ñ°÷
    ¼ÂÁõÊýË¡ÀâÌÀ
    ÇÓ¾Ū¥µ¥Ö¥¿¥¤¥×£³¥Æ¡¼¥Ö¥ëºî¤ë
    ¶¦Â¸Åª¥µ¥Ö¥¿¥¤¥×£±¥Æ¡¼¥Ö¥ëºî¤ê¡¢¥Ç¡¼¥¿¹àÌÜ(¥«¥é¥à)¤ÎÆâ»È¤ï¤Ê¤¤¹àÌÜ(¥«¥é¥à)¤ÏNULL¤Ë¤¹¤ë

ÏÀÍý¥Ç¡¼¥¿¥â¥Ç¥ë

  1. ÏÀÍý¥Ç¡¼¥¿¥â¥Ç¥ë¤Î¼ïÎà
    ¼ïÎàÀâÌÀ
    ³¬ÁØ·¿¥â¥Ç¥ëXML¤ÎÍͤ˿ƻҷ¿¤Î¥Ç¡¼¥¿¹½Â¤¡£¿Æ:»Ò¡á1:n
    ¥Í¥Ã¥È¥ï¡¼¥¯·¿¥â¥Ç¥ë¿Æ:»Ò¡án:n
    ´Ø·¸·¿¥Ç¡¼¥¿¥â¥Ç¥ë½ê°âRDB¤Î¥â¥Ç¥ë¡£¥É¥á¥¤¥ó¡Ê¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¡Ë¤È¥É¥á¥¤¥ó¤Î´Ø·¸(Relation)¤Ç¥Ç¡¼¥¿¹½Â¤¤ò¤¢¤é¤ï¤¹Êý¼°
  2. ´Ø·¸¥Ç¡¼¥¿¥â¥Ç¥ë
    1. ´Ø·¸
      ´Ø·¸É½µ­Ë¡ÀâÌÀ
      Ï£Ò∪£Ó¡á£ÔOR
      º¹£Ò¡Ý£Ó¡á£Ô
      ÀÑ£Ò∩£Ó¡á£ÔAND
      ľÀѣңأӡá£Ô£Ò¤ÎÍ×ÁǤȣӤÎÍ×ÁǤνçÎóÁȤ߹ç¤ï¤»¡££Ò1£Ó1¡¢£Ò1£Ó2¡¢...¡¢£Ò2£Ó1¡¢£Ò2£Ó2¡¢...
      ¾¦£Ò¡à£Ó¡á£Ô¤³¤Î¤È¤­ £Ó£Ø£Ô¡á£Ò
      ¼Í±Æ£Ò[A]¡á£Ô£Ò¤«¤é½Åʣ̵¤¯AÈÖÌܤÎÍ×ÁǤò¼è¤ê½Ð¤·¤¿¤â¤Î¡£SELECT DISTINCT A FROM R
      ÁªÂò£Ò[A¦ÈB]¡á£ÔSELECT * FROM R WHERE R.A ¦È R.B¡£¦È¤Ï²¿¤é¤«¤Î±é»»»Ò(=,>,<,etc.)
      Åù·ë¹ç£Ò[A¦ÈB]£Ó¡á£ÔSELECT * FROM R,S WHERE R.A ¦È S.B
      ¼«Á³·ë¹ç£Ò[A¦ÈB]£Ó¡á£ÔÅù·ë¹ç¤«¤é½ÅÊ£¤ò¼è¤ê½ü¤¤¤¿¤â¤Î¡£SELECT DISTINCT * FROM R,S WHERE R.A ¦È S.B
    2. ¥Ç¡¼¥¿¹½Â¤
      RDB´Ø·¸¥â¥Ç¥ë¤Ç¤¢¤é¤ï¤¹¤È³ÈÄ¥ER¿Þ¤Çɽ¤¹¤È
      ¥Æ¡¼¥Ö¥ë´Ø·¸¥¨¥ó¥Æ¥£¥Æ¥£
      Îó°À­Â°À­
      ¹Ô¥¿¥×¥ë¥ª¥«¥ì¥ó¥¹(¥¤¥ó¥¹¥¿¥ó¥¹)
    3. ¥¿¥×¥ë¤Î¼±ÊÌ»Ò
      ¼±ÊÌ»ÒÀâÌÀNULL°À­
      ¥¹¡¼¥Ñ¡¼¥­¡¼¥¿¥×¥ë¤ò°ì°Ì¤Ë¼±Ê̤Ǥ­¤ë°À­¤Î½¸¹ç²Ä
      ¸õÊ䥭¡¼¥¹¡¼¥Ñ¡¼¥­¡¼¤ÎÆâ¶Ë¾®¤Ê¤â¤Î¡£ÌµÂ̤ʹàÌܤò´Þ¤ó¤Ç¤¤¤Ê¤¤¤â¤Î²Ä
      ¼ç¥­¡¼(PRIMARY KEY)¸õÊ䥭¡¼¤ÎÆâ¼ÂºÝ¤Ë»È¤¦¤â¤ÎÉÔ²Ä
      ³°Éô¥­¡¼(FOREIGN KEY)´ØÏ¢Àè¤Î¥Æ¡¼¥Ö¥ë¤Î¼ç¥­¡¼¤¬Æþ¤ë¥«¥é¥àÉÔ²Ä
    4. ´Ø¿ô½¾Â°À­¿Þ¤«¤é¤Î¸õÊ䥭¡¼¤Î¸«¤Ä¤±Êý
      1. ´Ø¿ô½¾Â°À­¤Ë½¾¤¤¡¢Á´¤Æ¤Î°À­¤òƳ¤±¤ë°À­½¸¹ç¤ò¸«¤Ä¤±¤ë
      2. ÍפϤɤ³¤«¤é¤âÌð°õ¤¬Íè¤Æ¤¤¤Ê¤¤Â°À­¡Ê²¼¿Þ¤Î­¡­¤¡Ë¤ò¸«¤Ä¤±½Ð¤·¡¢¤½¤ì¤é¤ÎÁȤ߹ç¤ï¤»¤ÇÁ´¤Æ¤ÎÍ×ÁǤ¬ÀâÌÀ¤Ç¤­¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¤ë¡£
        ­¡¢ª­¢
            ¢­
            ­£
        
        ­¤¢ª­¥
    5. ¥Æ¡¼¥Ö¥ëÄêµÁ½ñ¤«¤é¼ç¥­¡¼¤Î¸«¤Ä¤±Êý
      1. ¡Á¥³¡¼¥É¤¬¼ç¥­¡¼¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤ó¤À¤í¤¦¤Ê¤¡¤ÈÌÜÀ±¤ò¤Ä¤±¤ë
      2. ER¿Þ¤ò½ñ¤¤¤Æ³°Éô¥­¡¼¤ÎÌÜÀ±¤ò¤Ä¤±¤ë
      3. ÌäÂêʸ¤òÆɤà

¥È¥é¥ó¥¶¥¯¥·¥ç¥ó

  1. ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ÏACID°À­¤ò»ý¤Ä
    A¸¶»ÒÀ­(Atomicity)¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ÏÁ´¤Æ¼Â¹Ô¤µ¤ì¤ë¤«¡¢Á´¤¯¼Â¹Ô¤µ¤ì¤Ê¤¤¤«¤Î¤É¤Á¤é¤«
    C°ì´ÓÀ­(Consistency)¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹ÆâÉô¤ÇÀ°¹çÀ­¤¬Êݤ¿¤ì¤ë
    IÆÈΩÀ­(Isolation)Ê£¿ô¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Áö¤Ã¤Æ¤â¡¢Ã±ÆȤǼ¹Ԥ·¤¿»þ¤ÈƱ¤¸·ë²Ì¤¬ÆÀ¤é¤ì¤ë
    DÂѵ×À­(Durability)¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¾ã³²¤¬È¯À¸¤·¤Æ¤â²óÉü¤Ç¤­¤ë¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
  2. ¸¶»ÒÀ­(A)
    • BEGIN / COMMIT / ROLLBACK
  3. °ì´ÓÀ­(C)
    • ¥í¥Ã¥¯¤Î¼ïÎà
      ¾¤Î¥æ¡¼¥¶¤«¤é¤Î¶¦Í­¥í¥Ã¥¯ÀêÍ­¥í¥Ã¥¯¤É¤ó¤Ê¤È¤­¤Ë¤Ä¤«¤¦¡©
      ¶¦Í­¥í¥Ã¥¯¡û¡ßÆɤ߹þ¤ß»þ¤Ë¾¤«¤éÊѹ¹¤µ¤ì¤¿¤¯¤Ê¤¤»þ
      ÀêÍ­¥í¥Ã¥¯¡ß¡ßÊѹ¹»þ
    • £²Áê¥í¥Ã¥¯
      ¶¦Í­¥í¥Ã¥¯¤·¤Æ¤«¤éÀêÍ­¥í¥Ã¥¯¤¹¤ë¤³¤È
      SELECT * FROM A_TBL WHERE id='000001' FOR UPDATE
      UPDATE a_COLUMN SET a_COLUMN='AAAA' WHERE id='000001'
    • ¥í¥Ã¥¯¤ÎγÅÙ
      1. DB
      2. TABLE
      3. PAGE
      4. TAPLE(RECORD)
    • ¥Ç¥Ã¥É¥í¥Ã¥¯
    • ¥æ¡¼¥¶Áàºî¤â´Þ¤ó¤À¥í¥Ã¥¯
      • ³Ú´Ñ¥í¥Ã¥¯?¡¦¡¦¡¦TIMESTAMP¹Ô¤äVERSION¹Ô¤Ê¤É¤ò»È¤Ã¤¿Áᤤ¼Ô¾¡¤Á¤ÎÊѹ¹
      • Èá´Ñ¥í¥Ã¥¯¡¦¡¦¡¦LOCK¥Õ¥é¥°¹Ô¤ò»È¤Ã¤Æ¾¤«¤é¥ì¥³¡¼¥É¤ò»Å¤¨¤Ê¤¯¤¹¤ë
  4. ÆÈΩÀ­(I)
    ISOLATION LEVELÊÌ̾¥À¡¼¥Æ¥£¡¼¥ê¡¼¥É·«¤êÊÖ¤·ÉԲĥե¡¥ó¥È¥à¥ê¡¼¥É
    0READ_UNCOMMITEDȯÀ¸È¯À¸È¯À¸
    1READ_COMMITEDËɤ²¤ëȯÀ¸È¯À¸
    2REPEATABLE_READËɤ²¤ëËɤ²¤ëȯÀ¸
    3SERIALIZABLEËɤ²¤ëËɤ²¤ëËɤ²¤ë
    • ¥À¡¼¥Æ¥£¡¼¥ê¡¼¥É
      • Ê̥ȥé¥ó¥¶¥¯¥·¥ç¥ó¤¬¥³¥ß¥Ã¥È¤·¤Æ¤¤¤Ê¤¤Êѹ¹¤¬¸«¤¨¤ë
    • ·«¤êÊÖ¤·ÉÔ²Ä
      • ¥È¥é¥ó¥¶¥¯¥·¥ç¥óÆâ¤Çȯ¹Ô¤·¤¿SELECTʸ¤ÈƱ¤¸SELECTʸ¤ò¤â¤¦°ìÅÙȯ¹Ô¤·¤Æ¤â·ë²Ì¤¬Æ±¤¸»ö¤ÏÊݾڤµ¤ì¤Ê¤¤
      • Ê̥ȥé¥ó¥¶¥¯¥·¥ç¥ó¤Ë¤è¤ëUPDATE¤¬µö²Ä¤µ¤ì¤Æ¤¤¤ë
    • ¥Õ¥¡¥ó¥È¥à¥ê¡¼¥É
      • ¥È¥é¥ó¥¶¥¯¥·¥ç¥óÆâ¤Çȯ¹Ô¤·¤¿SELECTʸ¤ÈƱ¤¸SELECTʸ¤ò¤â¤¦°ìÅÙȯ¹Ô¤·¤Æ¤¿¾ì¹ç¡¢¹Ô¿ô¤¬Áý¸º¤·¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë
      • Ê̥ȥé¥ó¥¶¥¯¥·¥ç¥ó¤Ë¤è¤ëINSERT/DELETE¤¬µö²Ä¤µ¤ì¤Æ¤¤¤ë
  5. Âѵ×À­(D)
          |          tx1À®¸ù        tx2À®¸ù
          | ----------->| ----------->| ------X
          |                               ¥·¥¹¥Æ¥à¾ã³²È¯À¸
    ¥Á¥§¥Ã¥¯¥Ý¥¤¥ó¥È                        (¸½¾õ)
    1. ¥í¡¼¥ë¥Ð¥Ã¥¯¡§¾ã³²È¯À¸»þ¤Ë¸½¾õ¤«¤é¥Á¥§¥Ã¥¯¥Ý¥¤¥ó¥È¤Î¾õÂÖ¤Þ¤ÇÌá¤ë¤³¤È
    2. ¥í¡¼¥ë¥Õ¥©¡¼¥ï¡¼¥É¡§¥Á¥§¥Ã¥¯¥Ý¥¤¥ó¥È¤«¤é¥³¥ß¥Ã¥È¤µ¤ì¤¿¾õÂÖ(tx2¥³¥ß¥Ã¥È)¤Þ¤Ç¿Ê¤á¤ë¤³¤È

ʬ»¶¥È¥é¥ó¥¶¥¯¥·¥ç¥ó

  1. 1Áꥳ¥ß¥Ã¥È
    #¼ç¥µ¥¤¥È(ÄÌ¿®)½¾¥µ¥¤¥È1½¾¥µ¥¤¥È2
    1½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥ÈÍ׵ᥳ¥ß¥Ã¥È
    2½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥ÈÍ׵ᥳ¥ß¥Ã¥È
    • (ÌäÂê)¾ã³²È¯À¸»þ¤Ë¥³¥ß¥Ã¥È¤·¤¿½¾¥µ¥¤¥È¤È¥í¡¼¥ë¥Ð¥Ã¥¯¤·¤¿½¾¥µ¥¤¥È¤¬¤Ç¤Æ¤·¤Þ¤¦
  2. 2Áꥳ¥ß¥Ã¥È
    #¼ç¥µ¥¤¥È(ÄÌ¿®)½¾¥µ¥¤¥È1½¾¥µ¥¤¥È2
    1½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥È½àÈ÷Í׵᥻¥­¥å¥¢¾õÂÖ
    2½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥È½àÈ÷Í׵᥻¥­¥å¥¢¾õÂÖ
    3½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥ÈÍ׵ᥳ¥ß¥Ã¥È
    4½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥ÈÍ׵ᥳ¥ß¥Ã¥È
    • (ÍøÅÀ)Á´¤Æ¤Î½¾¥µ¥¤¥È¤¬¥³¥ß¥Ã¥È¤Ç¤­¤ë¾õÂ֤ˤ¢¤ë¤³¤È¤ò³Îǧ¤·¤Æ¤«¤é¥³¥ß¥Ã¥È¤¹¤ë¤Î¤Ç¡¢£Ä£Â£Í£Ó¾å¤Î¥Ç¡¼¥¿¤Ëµ¯°ø¤¹¤ë¾ã³²¤Ë¤è¤ë½¾¥µ¥¤¥ÈƱ»Î¤ÎÉÔÀ°¹ç¤ÏËɤ²¤ë
    • (ÌäÂê)¾ã³²È¯À¸»þ¤Ë½¾¥µ¥¤¥È¤¬¥»¥­¥å¥¢¾õÂ֤ΤޤÞÂÔ¤Á³¤±¤Æ¤·¤Þ¤¦
  3. 3Áꥳ¥ß¥Ã¥È
    #¼ç¥µ¥¤¥È(ÄÌ¿®)½¾¥µ¥¤¥È1½¾¥µ¥¤¥È2
    1½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥È½àÈ÷Í׵᥻¥­¥å¥¢¾õÂÖ
    2½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥È½àÈ÷Í׵᥻¥­¥å¥¢¾õÂÖ
    3½¾¥µ¥¤¥È1¤Ë¥×¥ê¥³¥ß¥Ã¥ÈÍ×µá(¤Ê¤Ë¤â¤·¤Ê¤¤)
    4½¾¥µ¥¤¥È2¤Ë¥×¥ê¥³¥ß¥Ã¥ÈÍ×µá(¤Ê¤Ë¤â¤·¤Ê¤¤)
    3½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥ÈÍ׵ᥳ¥ß¥Ã¥È
    4½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥ÈÍ׵ᥳ¥ß¥Ã¥È
    • ½¾¥µ¥¤¥È¦¤Ç¥»¥­¥å¥¢¾õÂÖ¤«¤é¤Î¥¿¥¤¥à¥¢¥¦¥È½èÍý¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿
      1. ½¾¥µ¥¤¥È¤Ï°ìÄê»þ´ÖÆâ¤Ë¥×¥ê¥³¥ß¥Ã¥ÈÍ׵᤬ÆϤ«¤Ê¤¤¾ì¹ç¤Ë¤ÏROLLBACK
      2. ¤½¤Î¸å¼ç¥µ¥¤¥È¤«¤é¥×¥ê¥³¥ß¥Ã¥ÈÍ׵᤬Í褿¾ì¹ç¡¢¼ç¥µ¥¤¥È¤Ë¡Ö¤´¤á¤ó¡ª¼ç¥µ¥¤¥ÈÈ¿±þ¤¬ÃÙ¤¤¤«¤é¾¡¼ê¤ËROLLBACK¤·¤Á¤ã¤Ã¤¿¡×¤È¼Õ¤ë
      3. ¼ç¥µ¥¤¥È¤Ïʬ»¶¥È¥é¥ó¥¶¥¯¥·¥ç¥óÁ´ÂΤòROLLBACK¤¹¤ì¤Ð¡¢½¾¥µ¥¤¥È´Ö¤Î°ì´ÓÀ­¤ÏÊÝ»ý¤µ¤ì¤ë(Á´¤Æ¤Î½¾¥µ¥¤¥È¤¬ROLLBACK¤µ¤ì¤ë)

¥Á¥å¡¼¥Ë¥ó¥°

  1. INDEX
    CREATE INDEX ½¾¶È°÷ŽÃŽ°ŽÌŽÞŽÙINDEXɽ ON ½¾¶È°÷ŽÃŽ°ŽÌŽÞŽÙ (name(10))
    ̾Á°¤ÎºÇ½é10ʸ»ú¤Ç¥¤¥ó¥Ç¥Ã¥¯¥¹É½¤òºî¤ë
    1. INDEX¤Î¼ÂÁõ(Hash)
      1. Keyword : ¥·¥Î¥Ë¥à¡¦¡¦¡¦½ÅÊ£¤·¤¿Hash¥­¡¼
      2. Keyword : ¥ª¡¼¥×¥ó¥Ï¥Ã¥·¥å¡¦¡¦¡¦ ¥·¥Î¥Ë¥à¤¬È¯À¸¤·¤¿»þ¤Ë¤ÏºÇ´ó¤ê¤Î¤¢¤¤¤Æ¤¤¤ë¥Ï¥Ã¥·¥åÃͤò»È¤¦
      3. Keyword : ¥Á¥§¥¤¥Ë¥ó¥°¡¦¡¦¡¦HashÃͤò¥ê¥¹¥È¤Ë¤¹¤ë
        °ìÈ̤ÎHashɽ
         Hash¥­¡¼ HashÃÍ
         0001     AAAAA
         0002     BBBBB
         0003     CCCCC
        
        ¥Á¥§¥¤¥Ë¥ó¥°Ë¡
         Hash¥­¡¼ HashÃͤΥꥹ¥È
         0001     AAAAA,AAAAB,AAAAC
         0002     BBBBB,BBBBC,BBBBD
         0003     CCCCC,CCCCD,CCCCE
    2. B Tree
    3. B+ Tree : B Tree¤Î¥ê¡¼¥Õ¤Î¥ê¥¹¥È¤òÍÑ°Õ¤·¤Æ¥·¡¼¥±¥ó¥¹¥¢¥¯¥»¥¹¤ÎÀ­Ç½¤ò¹â¤á¤¿¤â¤Î
  2. ÈóÀµµ¬²½¡ÊÉûÌ䤤¹ç¤ï¤»¤¬ÉÑȯ¤¹¤ë¾ì¹ç¡Ë
  3. ¥í¥Ã¥¯¤ÎγÅÙ¤ò¾®¤µ¤¯¤Ç¤­¤Ê¤¤¤«¡©
  4. DB¥Õ¥¡¥¤¥ë¤¬¾è¤Ã¤Æ¤¤¤ë¥Ç¥£¥¹¥¯¤òʬ¤±¤ë
  5. ¥Ç¥£¥¹¥¯¥­¥ã¥Ã¥·¥å/¥á¥â¥ê ¤òÂô»³ÀѤà

Àµµ¬²½

  1. ÂènÀµµ¬·Á
    Àµµ¬·Á¥Æ¡¼¥Ö¥ëÆâ¤Î°À­¤òÁ´¤Æñ½ã°À­¤Ë¤¹¤ë¥Æ¡¼¥Ö¥ëÆâ¤Î¥­¡¼¹àÌܤËÂФ¹¤ëÉôʬ´Ø¿ô½¾Â°¤òºï½ü¥Æ¡¼¥Ö¥ëÆâ¤Î¿ä°ÜŪ´Ø¿ô½¾Â°¤òºï½ü
    ÈóÀµµ¬·Á¡ß¡ß¡ß
    Âè°ìÀµµ¬·Á¡û¡ß¡ß
    ÂèÆóÀµµ¬·Á¡û¡û¡ß
    Âè»°Àµµ¬·Á¡û¡û¡û
  2. Àµµ¬²½¤·¤Æ¤âÎɤ¤¤Î¤«¡©
    • Àµµ¬²½¤Ï¡Ö¾ðÊó̵»¼ºÊ¬²ò¡×
  3. ¤Ê¤¼Àµµ¬²½¤¹¤ë¤Î¤«¡©
    • ¡Ö¹¹¿·»þ°Û¾ï¡×¤òµ¯¤³¤µ¤Ê¤¤°Ù
    • ¥Þ¥¹¥¿¹àÌܤ¬»¶ºß¤·¤Æ¤¤¤ë¤È¡Ê¤¿¤È¤¨¤Ð¼õÃí¤´¤È¤Ëñ²Á¤ä¾¦ÉÊ̾¤ò»ý¤Ã¤Æ¤¤¤ë¤È¡Ë¹¹¿·»þ¤ËÁ´¤Æ¤Î¥ì¥³¡¼¥É¤òÄ´¤Ù¤ÆÊѹ¹¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¤½¤ó¤Ê¤ÎÀäÂв¿¤«ÊѤʤ³¤È¤¬µ¯¤­¤ë¤Ã¤Æ¡ª¤È¤¤¤¦¤³¤È
    • ¡Ö°ì»ö¼Â°ì¥«½ê¡×ÍפϾðÊó¤Î¶É½ê²½¤È¤¤¤¦¤¢¤¿¤ê¤Þ¤¨¤Î¤³¤È
  4. Âè°ìÀµµ¬²½
    • ·«¤êÊÖ¤·Â°À­(Èóñ½ã°À­)¤òÇÓ½ü
      -----------------------------------------------------------------------------
      ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ1 ¾¦ÉÊ̾1 ñ²Á1 ¾¦ÉÊÈÖ¹æ2 ¾¦ÉÊ̾2 ñ²Á2 ¾¦ÉÊÈÖ¹æ3 ¾¦ÉÊ̾3 
      ñ²Á3 ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê
      PK(¼õÃíÈÖ¹æ)
      -----------------------------------------------------------------------------
                                 ¢­
      -----------------------------------------------------------------------------
      ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê
      PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ)
      -----------------------------------------------------------------------------
  5. ÂèÆóÀµµ¬²½
    • Âè°ìÀµµ¬²½¤ò¹Ô¤Ã¤¿¸å
    • ¥­¡¼¹àÌܤËÂФ¹¤ëÉôʬ´Ø¿ô½¾Â°¤Ê¹Ô¤ò¤òºï½ü(¥­¡¼¹àÌܤ¬Ê¬¤«¤ì¤ÐľÀÜʬ¤«¤ë¤â¤Î¤òºï½ü)
      -----------------------------------------------------------------------------
      ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á ¾®·× ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê
      PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ)
      -----------------------------------------------------------------------------
                                 ¢­
      -----------------------------------------------------------------------------
      ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¿ôÎÌ ¾®·× ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê
      PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ)
      
      ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á PK(¾¦ÉÊÈÖ¹æ)
      -----------------------------------------------------------------------------
  6. Âè»°Àµµ¬²½
    • ÂèÆóÀµµ¬²½¤ò¹Ô¤Ã¤¿¸å
    • ¥­¡¼¹àÌܤ«¤é¤Î¿ä°ÜŪ´Ø¿ô½¾Â°¤ÊÈó¥­¡¼¹àÌܤòºï½ü(¥­¡¼¹àÌܤ¬Ê¬¤«¤ì¤Ð´ÖÀÜŪ¤Ëʬ¤«¤ëÈó¥­¡¼¹àÌܤòºï½ü)
    • Ƴ½Ð¹àÌܤòºï½ü
      -----------------------------------------------------------------------------
      ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¿ôÎÌ ¾®·× ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê
      PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ)
      
      ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á PK(¾¦ÉÊÈÖ¹æ)
      -----------------------------------------------------------------------------
                                 ¢­
      -----------------------------------------------------------------------------
      ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¿ôÎÌ ¸ÜµÒÈÖ¹æ    ¢¨¾®·×¤òºï½ü
      PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ)
      
      ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á PK(¾¦ÉÊÈÖ¹æ)
      
      ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¸ÜµÒÈÖ¹æ)
      -----------------------------------------------------------------------------
  7. Âè»°Àµµ¬²½¤Ç»ß¤á¤¿Êý¤¬Îɤ¤Íýͳ
    1. ¡ÖÁ´ÂΤΥǡ¼¥¿¹½Â¤¤«¤é¶È̳Ū¤Ê´Ø·¸À­¤¬¼º¤ï¤ì¤ë¤«¤é¡×
  8. Âè»ÍÀµµ¬²½
    • ¿Ãͽ¾Â°À­
      id°À­X°À­Y°À­Z
      t11aA
      t21aB
      t31bA
      t41bB
      t1,t4¤¬¤¢¤ì¤Ð¡¢t2,t3¤â¤¢¤ë¤è¤¦¤Ê´Ø·¸(¤½¤ó¤Ê¥Ç¡¼¥¿¸½¼ÂŪ¤Ëºß¤ë¤ó¤«¤¤¤Ê¡©)
    • Âè»°Àµµ¬²½¤ò¹Ô¤Ã¤¿¸å
    • ¿Ãͽ¾Â°À­¤Î¤¢¤ë¹àÌܤǥơ¼¥Ö¥ë¤òʬ³ä¤¹¤ë
      -----------------------------------------------------------------------------
      ¾¦ÉʼïÊÌ ¾¦ÉÊ̾ À½Â¤¸µ PK(¾¦ÉÊÈÖ¹æ) // ¥Ü¥¤¥¹¥´¥Ã¥ÈÀµµ¬²½ºÑ¤ß
      -----------------------------------------------------------------------------
                                 ¢­
      -----------------------------------------------------------------------------
      ¾¦ÉʼïÊÌ ¾¦ÉÊ̾ PK(¾¦ÉʼïÊÌ)
      ¾¦ÉʼïÊÌ À½Â¤¸µ PK(¾¦ÉʼïÊÌ)
      -----------------------------------------------------------------------------
  9. Âè¸ÞÀµµ¬²½
    • Âè»°Àµµ¬²½¤ò¹Ô¤Ã¤¿¸å
    • ¥­¡¼¹àÌܤǥơ¼¥Ö¥ë¤òʬ³ä¤¹¤ë
    • ·ë¹ç½¾Â°À­¤òËþ¤¿¤¹ºÇ¾®¤Î¥Æ¡¼¥Ö¥ë¹½À®¤Ë¤¹¤ë¡£¤Ä¤Þ¤êɽ·ë¹ç¤Ë¤è¤ê¸µ¤Î¾ðÊó¤¬Éü¸µ¤Ç¤­¤ëºÇ¾®Ã±°Ì¤Þ¤Ç¥Æ¡¼¥Ö¥ë¤òʬ³ä¤¹¤ë¤³¤È¡£
      -----------------------------------------------------------------------------
      ²·ÀèŹ ¾¦ÉʼïÊÌ À½Â¤¸µ¥á¡¼¥«¡¼(PK ²·ÀèŹ,¾¦ÉʼïÊÌ,À½Â¤¸µ)
      -----------------------------------------------------------------------------
                                 ¢­
      -----------------------------------------------------------------------------
      ²·ÀèŹ ¾¦ÉʼïÊÌ         (PK ²·ÀèŹ,¾¦ÉʼïÊÌ)
      ²·ÀèŹ À½Â¤¸µ¥á¡¼¥«¡¼   (PK ²·ÀèŹ,À½Â¤¸µ)
      ¾¦ÉʼïÊÌ À½Â¤¸µ¥á¡¼¥«¡¼ (PK ¾¦ÉʼïÊÌ,À½Â¤¸µ)
      -----------------------------------------------------------------------------
  10. ¥Ü¥¤¥¹¡¦¥´¥Ã¥ÈÀµµ¬²½
    • ¥Æ¡¼¥Ö¥ëÆâ¤ÎÁ´¤Æ¤Î°À­¤¬¥­¡¼¹àÌܤȤμ«ÌÀ¤Ê´Ø¿ô½¾Â°À­¤Ë¤¢¤ë¤â¤Î
      Y ¢¾ X ¤Î¤È¤­¡¢X->Y¤¬¾ï¤ËÀ®Î©¤¹¤ë¤³¤È
      ex.
      X : ¾¦ÉÊÈÖ¹æ
      Y : ¾¦ÉÊÈֹ桢¾¦ÉÊ̾¡¢Ã±²Á
    • ¥Ü¥¤¥¹¡¦¥´¥Ã¥ÈÀµµ¬²½¤ÏÂè¸ÞÀµµ¬²½(½¾¤Ã¤ÆÂè°ì¡¦Æ󡦻°Àµµ¬²½¤â¡Ë¤òËþ¤¿¤¹
    • ¥Ü¥¤¥¹¡¦¥´¥Ã¥ÈÀµµ¬²½¤µ¤ì¤Æ¤¤¤ë¤«¤é¤È¤¤¤Ã¤ÆÂè»ÍÀµµ¬²½¤µ¤ì¤Æ¤¤¤ë¤È¤Ï¸Â¤é¤Ê¤¤

SQLʸ(¥Æ¡¼¥Ö¥ë´ÉÍý)

  1. CREATE SCHEMA
    CREATE SCHEMA ¥¹¥­¡¼¥Þ̾ AUTHORIZATION ¥æ¡¼¥¶
  2. CREATE TABLE
    CREATE TABLE USER_TBL (
      ID   NUMERIC(16),
      NAME VARCHAR(255) NOT NULL,
      AGE  NUMERIC(3)   CHECK(AGE<30),
      SEX  CHAR(1)      DEFAULT "F",
      MAIL VARCHAR(255) NOT NULL,
      PRIMARY KEY (ID)
    )
    
    CREATE TABLE MESSAGE_BOX_TBL (
      MESSAGE_ID NUMERIC(16) PRIMARY KEY,
      MESSAGE    BLOB,
      USER_ID    NUMERIC(16) NOT NULL,
    
      FOREIGN KEY (USER_ID) REFERENCES USER_TBL(ID)
        ON DELETE CASCADE
        ON UPDATE CASCADE
    )
    • FOREIGN KEY ¤Ç»ØÄꤹ¤ë¹àÌܤϡ¢¼ç¥­¡¼¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
    • FOREING KEY ¤ËÂФ·¤Æ¡¢»²¾ÈÀ褬Êѹ¹¤µ¤ì¤¿»þ¤ÎÆ°ºî¤ò»ØÄê¤Ç¤­¤ë
      1. ON DELETE : »²¾ÈÀè¥Æ¡¼¥Ö¥ë¦¤Ç¥ì¥³¡¼¥É¤¬ºï½ü¤µ¤ì¤¿¤È¤­
        NO ACTION²¿¤â¤·¤Ê¤¤¡£FOREIGN KEY°À­¤ËON¡Á¤ò½ñ¤«¤Ê¤¤¤È¤³¤ì¤¬ÀßÄꤵ¤ì¤ë
        CASCADE¥ì¥³¡¼¥É¤òºï½ü¤¹¤ë
        SET NULL³°Éô»²¾ÈÎó¤ËNULL¤ò¥»¥Ã¥È
        SET DEFAULT³°Éô»²¾ÈÎó¤Ë¥Ç¥Õ¥©¥ë¥ÈÃͤò¥»¥Ã¥È
      2. ON UPDATE : ¥Þ¥¹¥¿¥Æ¡¼¥Ö¥ë¦¤Ç¥ì¥³¡¼¥É¤¬¹¹¿·¤µ¤ì¤¿¤È¤­
        NO ACTION²¿¤â¤·¤Ê¤¤¡£FOREIGN KEY°À­¤ËON¡Á¤ò½ñ¤«¤Ê¤¤¤È¤³¤ì¤¬ÀßÄꤵ¤ì¤ë
        CASCADE³°Éô»²¾ÈÎó¤ò¹¹¿·¤¹¤ë
        SET NULL³°Éô»²¾ÈÎó¤ËNULL¤ò¥»¥Ã¥È
        SET DEFAULT³°Éô»²¾ÈÎó¤Ë¥Ç¥Õ¥©¥ë¥ÈÃͤò¥»¥Ã¥È
  3. CREATE ASSERTION (ɽÌÀ¡§TABLE¤ËÂФ¹¤ë¸åÉÕ¤ÎÀ©Ìó)
    CREATE ASSERTION USER_TBL CHECK( AGE>18 AND AGE<30 )
  4. CREATE VIEW
    CREATE VIEW USER_POSTING_LIST ( ID , NAME , MSG_ID , MSG ) AS
      SELECT USER.ID , USER.NAME , MSG.MESSAGE_ID , MSG.MESSAGE
        FROM USER_TBL USER , MESSAGE_BOX MSG
        WHERE USER.MAIL = MSG.MAIL
    • ¹¹¿·¡¦ºï½ü¤Ç¤­¤Ê¤¤VIEWɽ
      1. ½¸¹ç´Ø¿ô¤ò»È¤Ã¤¿¤â¤Î(AVG,MAX¤Ê¤É)
      2. GROUP BY,ORDER BY¤ò»È¤Ã¤¿¤â¤Î
      3. ɽ¤Î·ë¹ç¤ä¹çÊ»¤ò¤·¤Æ¤¤¤ë¤â¤Î
      4. ÉûÌ䤤¹ç¤ï¤»¤ò¤·¤Æ¤¤¤ë¤â¤Î
      5. DISTINCT¶ç¤Ç½ÅÊ£¤òÇÓ½ü¤·¤Æ¤¤¤ë¤â¤Î
  5. DROP TABLE USER_TBL
  6. DROP VIEW USER_POSTING_LIST
  7. GRANT ¸¢¸Â ON ¥Æ¡¼¥Ö¥ë/¥Ó¥å¡¼ TO ¥æ¡¼¥¶¡¼[,¥æ¡¼¥¶¡¼]
    ¸¢¸Â¤Ç¤­¤ë¤³¤È
    ALL PRIVILEGESÁ´Éô
    SELECTSELECT
    INSERTINSERT
    DELETEDELETE
    UPDATEUPDATE
    • VIEWɽ¤ËÂФ¹¤ë¸¢¸Â¤Ï¡¢»²¾È¤¹¤ëÁ´¤Æ¤Î¼ÂTABLE¤ËÂФ¹¤ë¸¢¸Â¤¬É¬Í×
  8. REVOKE ¸¢¸Â ON ¥Æ¡¼¥Ö¥ë/¥Ó¥å¡¼ TO ¥æ¡¼¥¶¡¼[,¥æ¡¼¥¶¡¼]

SQLʸ(SELECT)

  1. SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë
  2. ɽ¼¨¤¹¤ëÎó¤ò»ØÄꤹ¤ë
    SELECT
     ¾¦ÉÊÈÖ¹æ ,
     Àµ²Á
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
  3. ¹Ô¿ô¤òÊÖ¤¹
    SELECT
     COUNT(*)
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
  4. ·×»»¤¹¤ë
    SELECT
     ¾¦ÉÊÈÖ¹æ ,
     Àµ²Á ,
     Àµ²Á*1.05 AS ÀÁµá³Û
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
  5. Îó¤òÏ¢·ë
    SELECT 
     '¾¦ÉÊÈÖ¹æ='|| ¾¦ÉÊÈÖ¹æ ,
     'Àµ²Á='|| Àµ²Á ,
     'ÀÁµá³Û='|| Àµ²Á*1.05 AS ÀÁµá³Û 
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
  6. ¾ò·ï¸¡º÷
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ¸ÜµÒID='00456'
  7. NULLÃͤθ¡º÷
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ǼÉÊÀè½»½ê IS NULL
  8. ½ÅÊ£¤ò¼è¤ê½ü¤¯(Îã¤ÏID00456¤Î¸ÜµÒ¤¬²áµî¤ËÃíʸ¤·¤¿¾¦ÉʤΰìÍ÷)
    SELECT DISTINCT
     ¾¦ÉÊÈÖ¹æ
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ¸ÜµÒID='00456'
  9. ÈÏ°Ï»ØÄ긡º÷
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ¼õÃíÆü BETWEEN '2000-01-01' AND '2004-12-31'
     
    (eq.)
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ¼õÃíÆü >= '2000-01-01' AND ¼õÃíÆü <='2004-12-31'
  10. Ê£¿ô¤«¤é¤ÎÁªÂò¸¡º÷
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ¼õÃíÆü IN('2003-11-10','2003-11-11')
  11. ÉûÌ䤤¹ç¤ï¤»(µÙ¶ÈÆü¤Î¼õÃí°ìÍ÷)
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    WHERE ¼õÃíÆü IN( SELECT Æü»þ
                     FROM ÆüÉÕ¥Þ¥¹¥¿
                     WHERE Æü»þ°À­='µÙ¶È' )
     
    SELECT *
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë X
    WHERE EXISTS( SELECT *
                  FROM ÆüÉÕ¥Þ¥¹¥¿ Y
                  WHERE X.¼õÃíÆü = Y.ÆüÉÕ AND Y.Æü»þ°À­='µÙ¶È' )
  12. WHERE LIKE '¥Ó¥Ã¥¯%'
    • "_":°ì·å¤ÎǤ°Õ¤Îʸ»ú
    • "%":£°·å¤ò´Þ¤à£Î·å¤ÎǤ°Õ¤Îʸ»ú

SQLʸ(GROUP BY/ORDER BY)

  1. SELECT ¼õÃíÆü,AVG(¼õÃí¶â³Û) AS Ê¿¶Ñ¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü
  2. SELECT ¼õÃíÆü,MAX(¼õÃí¶â³Û) AS ºÇÂç¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü
  3. SELECT ¼õÃíÆü,MIN(¼õÃí¶â³Û) AS ºÇ¾®¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü
  4. SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü
  5. SELECT ¼õÃíÆü,COUNT(*) AS ¼õÃí·ï¿ô FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü
  6. GROUP¤ËÂФ·¤Æ¾ò·ï¤òÉÕ¤±¤ë
    1·ï°Ê¾å¤Î¼õÃí¤¬¤¢¤Ã¤¿Æü¤Î¼õÃí¶â³Û¤Î¹ç·×
    SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    GROUP BY ¼õÃíÆü
    HAVING COUNT(*) > 0
  7. ¾º½ç(¾®¢ªÂç)
    SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    GROUP BY ¼õÃíÆü
    ORDER BY ¼õÃíÆü  // ¾Êά»þ¤ÏASC
     
    SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    GROUP BY ¼õÃíÆü
    ORDER BY ¼õÃíÆü ASC
  8. ¹ß½ç(Â碪¾®)
    SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û
    FROM ¼õÃí¥Æ¡¼¥Ö¥ë
    GROUP BY ¼õÃíÆü
    ORDER BY 2 DESC
    ORDER BY¤Î¸å¤ËSQL´Ø¿ô¤ò½ñ¤¯¤È¥¨¥é¡¼ ¢ª ¹Ô¿ô¤Ç»ØÄê

SQLʸ(JOIN)

  1. ¤³¤³¤Ç°·¤¦¥Æ¡¼¥Ö¥ë
    • UPPER_TBL
      IDPHRASE
      1½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß
      2½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î
      3¤¢¤·¤Ó¤­¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î
      4ÅĻҤαº¤Ë ¤¦¤Á½Ð¤Ç¤Æ¸«¤ì¤Ð Çò̯¤Î
      5±ü»³¤Ë ¹ÈÍդդߤ櫓 ÌĤ¯¼¯¤Î
    • LOWER_TBL
      IDPHRASE
      1²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä
      2°á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³
      3¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à
      6Çò¤­¤ò¸«¤ì¤Ð Ì뤾¹¹¤±¤Ë¤±¤ë
      7»°³Þ¤Î»³¤Ë ½Ð¤Ç¤··î¤«¤â
  2. ÆâÉô·ë¹ç(INNER JOIN)
    SELECT U.ID , U.PHRASE , L.PHRASE
    FROM UPPER_TBL U , LOWER_TBL L 
    WHERE U.ID = L.ID
     
    U.IDU.PHRASEL.PHRASE
    1½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä
    2½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î°á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³
    3¤¢¤·¤Ó¤­¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à
  3. ³°Éô·ë¹ç(OUTER JOIN)
    1. Á´³°Éô·ë¹ç(FULL JOIN)
      SELECT U.ID , U.PHRASE , L.PHRASE
      FROM UPPER_TBL U FULL JOIN LOWER_TBL L ON U.ID = L.ID
      U.IDU.PHRASEL.PHRASE
      1½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä
      2½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î°á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³
      3¤¢¤·¤Ó¤­¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à
      4ÅĻҤαº¤Ë ¤¦¤Á½Ð¤Ç¤Æ¸«¤ì¤Ð Çò̯¤Înull
      5±ü»³¤Ë ¹ÈÍդդߤ櫓 ÌĤ¯¼¯¤Înull
      6nullÇò¤­¤ò¸«¤ì¤Ð Ì뤾¹¹¤±¤Ë¤±¤ë
      7null»°³Þ¤Î»³¤Ë ½Ð¤Ç¤··î¤«¤â
    2. º¸³°Éô·ë¹ç(LEFT JOIN)
      SELECT U.ID , U.PHRASE , L.PHRASE
      FROM UPPER_TBL U LEFT JOIN LOWER_TBL L ON U.ID = L.ID
      U.IDU.PHRASEL.PHRASE
      1½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä
      2½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î°á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³
      3¤¢¤·¤Ó¤­¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à
      4ÅĻҤαº¤Ë ¤¦¤Á½Ð¤Ç¤Æ¸«¤ì¤Ð Çò̯¤Înull
      5±ü»³¤Ë ¹ÈÍդդߤ櫓 ÌĤ¯¼¯¤Înull
    3. ±¦³°Éô·ë¹ç(FULL JOIN)
      SELECT L.ID , U.PHRASE , L.PHRASE
      FROM UPPER_TBL U RIGHT JOIN LOWER_TBL L ON U.ID = L.ID
      L.IDU.PHRASEL.PHRASE
      1½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä
      2½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î°á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³
      3¤¢¤·¤Ó¤­¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à
      6nullÇò¤­¤ò¸«¤ì¤Ð Ì뤾¹¹¤±¤Ë¤±¤ë
      7null»°³Þ¤Î»³¤Ë ½Ð¤Ç¤··î¤«¤â

SQLʸ(INSERT/UPDATE/DELETE)

  1. INSERT
    INSERT
     INTO ¼õÃí¥Æ¡¼¥Ö¥ë(
                  ¼õÃíID
                  ¸ÜµÒID,
                  ¾¦ÉÊID,
                  ¿ôÎÌ,
                  ǼÉʎ̎׎¸ŽÞ,
                  ¼õÃíÆü
                  ǼÉÊÆü,
                  ºï½üŽÌŽ×Ž¸ŽÞ)
     VALUES( '034564',
             '130576'
             'J94045',
             4,
             0
             '2005-03-31'
             null
             '0')
  2. UPDATE
    UPDATE ¼õÃí¥Æ¡¼¥Ö¥ë 
     SET ǼÉʎ̎׎¸ŽÞ=1 , ǼÉÊÆü='2005-04-02'
     WHERE ¼õÃíID = '034564'
  3. DELETE
    DELETE FROM ¼õÃí¥Æ¡¼¥Ö¥ë
     WHERE ºï½üŽÌŽ×Ž¸ŽÞ='1'

SQLʸ(¥È¥é¥ó¥¶¥¯¥·¥ç¥ó)

  1. BEGIN
  2. COMMIT
  3. ROLLBACK

Computer


¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS   sitemap
Last-modified: 2006-02-16 (ÌÚ) 22:35:26 (6870d)
Short-URL: http://at-sushi.com/pukiwiki/index.php?cmd=s&k=e2e575d2d8
ISBN10
ISBN13
9784061426061