¥â¥Ç¥ë¤Ç¤¤¤¦¤È | ¥¹¥¡¼¥Þ¤Ç¤¤¤¦¤È | ¶ñÂÎÎã¡¢À®²Ìʪ |
(¥×¥í¥°¥é¥à) | (DBÀ߷פ«¤é¸«¤ë¤È)¥æ¡¼¥¶¥¤¥ó¥¿¥Õ¥§¡¼¥¹ | |
³°Éô¥¹¥¡¼¥Þ | SQL¥Ó¥å¡¼¡£ÏÀÍý¥Ç¡¼¥¿ÆÈΩÀ | |
³µÇ°¥Ç¡¼¥¿¥â¥Ç¥ë | ³µÇ°¥¹¥¡¼¥Þ | ER¿Þ¡£¶È̳»ÅÍÍ |
ÏÀÍý¥Ç¡¼¥¿¥â¥Ç¥ë | ÆâÉô¥¹¥¡¼¥Þ | ¥Æ¡¼¥Ö¥ëÄêµÁµÁ¡£ÊªÍý¥Ç¡¼¥¿ÆÈΩÀ |
ʪÍý¥Ç¡¼¥¿¥Ù¡¼¥¹ | ¥Ç¡¼¥¿¥Ù¡¼¥¹ | ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯ÊªÍýÀß·× |
Ž¶Ž°ŽÃŽÞŽ¨ŽÅŽØŽÃŽ¨(¿½ÅÅÙ) 1 n n n [¸ÜµÒ]----->[¼õÃí]<----->[¾¦ÉÊ] Ž´ŽÝŽÃŽ¨ŽÃŽ¨ ´ØÏ¢ Ž´ŽÝŽÃŽ¨ŽÃŽ¨
1 n 1 n n 1 [¸ÜµÒ]----->[¼õÃí]----->[¼õÃíÌÀºÙ]<----[¾¦ÉÊ]
²ñ°÷ ¥¹¡¼¥Ñ¡¼¥¿¥¤¥× ¡Ã ¡²¢¤¡² ¡Ã ¡Ã Ë¡¿Í ¸Ä¿Í ¥µ¥Ö¥¿¥¤¥× ²ñ°÷ ²ñ°÷
¼ÂÁõÊýË¡ | ÀâÌÀ |
ÇÓ¾Ū¥µ¥Ö¥¿¥¤¥× | £³¥Æ¡¼¥Ö¥ëºî¤ë |
¶¦Â¸Åª¥µ¥Ö¥¿¥¤¥× | £±¥Æ¡¼¥Ö¥ëºî¤ê¡¢¥Ç¡¼¥¿¹àÌÜ(¥«¥é¥à)¤ÎÆâ»È¤ï¤Ê¤¤¹àÌÜ(¥«¥é¥à)¤ÏNULL¤Ë¤¹¤ë |
¼ïÎà | ÀâÌÀ |
³¬ÁØ·¿¥â¥Ç¥ë | XML¤ÎÍͤ˿ƻҷ¿¤Î¥Ç¡¼¥¿¹½Â¤¡£¿Æ:»Ò¡á1:n |
¥Í¥Ã¥È¥ï¡¼¥¯·¿¥â¥Ç¥ë | ¿Æ:»Ò¡án:n |
´Ø·¸·¿¥Ç¡¼¥¿¥â¥Ç¥ë | ½ê°âRDB¤Î¥â¥Ç¥ë¡£¥É¥á¥¤¥ó¡Ê¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¡Ë¤È¥É¥á¥¤¥ó¤Î´Ø·¸(Relation)¤Ç¥Ç¡¼¥¿¹½Â¤¤ò¤¢¤é¤ï¤¹Êý¼° |
´Ø·¸ | ɽµË¡ | ÀâÌÀ |
Ï | £Ò∪£Ó¡á£Ô | 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 |
RDB | ´Ø·¸¥â¥Ç¥ë¤Ç¤¢¤é¤ï¤¹¤È | ³ÈÄ¥ER¿Þ¤Çɽ¤¹¤È |
¥Æ¡¼¥Ö¥ë | ´Ø·¸ | ¥¨¥ó¥Æ¥£¥Æ¥£ |
Îó | °À | °À |
¹Ô | ¥¿¥×¥ë | ¥ª¥«¥ì¥ó¥¹(¥¤¥ó¥¹¥¿¥ó¥¹) |
¼±ÊÌ»Ò | ÀâÌÀ | NULL°À |
¥¹¡¼¥Ñ¡¼¥¡¼ | ¥¿¥×¥ë¤ò°ì°Ì¤Ë¼±Ê̤Ǥ¤ë°À¤Î½¸¹ç | ²Ä |
¸õÊ䥡¼ | ¥¹¡¼¥Ñ¡¼¥¡¼¤ÎÆâ¶Ë¾®¤Ê¤â¤Î¡£ÌµÂ̤ʹàÌܤò´Þ¤ó¤Ç¤¤¤Ê¤¤¤â¤Î | ²Ä |
¼ç¥¡¼(PRIMARY KEY) | ¸õÊ䥡¼¤ÎÆâ¼ÂºÝ¤Ë»È¤¦¤â¤Î | ÉÔ²Ä |
³°Éô¥¡¼(FOREIGN KEY) | ´ØÏ¢Àè¤Î¥Æ¡¼¥Ö¥ë¤Î¼ç¥¡¼¤¬Æþ¤ë¥«¥é¥à | ÉÔ²Ä |
¡¢ª¢ ¢ £ ¤¢ª¥
A | ¸¶»ÒÀ(Atomicity) | ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ÏÁ´¤Æ¼Â¹Ô¤µ¤ì¤ë¤«¡¢Á´¤¯¼Â¹Ô¤µ¤ì¤Ê¤¤¤«¤Î¤É¤Á¤é¤« |
C | °ì´ÓÀ(Consistency) | ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹ÆâÉô¤ÇÀ°¹çÀ¤¬Êݤ¿¤ì¤ë |
I | ÆÈΩÀ(Isolation) | Ê£¿ô¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Áö¤Ã¤Æ¤â¡¢Ã±ÆȤǼ¹Ԥ·¤¿»þ¤ÈƱ¤¸·ë²Ì¤¬ÆÀ¤é¤ì¤ë |
D | Âѵ×À(Durability) | ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¾ã³²¤¬È¯À¸¤·¤Æ¤â²óÉü¤Ç¤¤ë¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ |
¾¤Î¥æ¡¼¥¶¤«¤é¤Î | ¶¦Í¥í¥Ã¥¯ | ÀêÍ¥í¥Ã¥¯ | ¤É¤ó¤Ê¤È¤¤Ë¤Ä¤«¤¦¡© |
¶¦Í¥í¥Ã¥¯ | ¡û | ¡ß | Æɤ߹þ¤ß»þ¤Ë¾¤«¤éÊѹ¹¤µ¤ì¤¿¤¯¤Ê¤¤»þ |
ÀêÍ¥í¥Ã¥¯ | ¡ß | ¡ß | Êѹ¹»þ |
¶¦Í¥í¥Ã¥¯¤·¤Æ¤«¤éÀêÍ¥í¥Ã¥¯¤¹¤ë¤³¤È SELECT * FROM A_TBL WHERE id='000001' FOR UPDATE UPDATE a_COLUMN SET a_COLUMN='AAAA' WHERE id='000001'
ISOLATION LEVEL | ÊÌ̾ | ¥À¡¼¥Æ¥£¡¼¥ê¡¼¥É | ·«¤êÊÖ¤·ÉÔ²Ä | ¥Õ¥¡¥ó¥È¥à¥ê¡¼¥É |
0 | READ_UNCOMMITED | ȯÀ¸ | ȯÀ¸ | ȯÀ¸ |
1 | READ_COMMITED | Ëɤ²¤ë | ȯÀ¸ | ȯÀ¸ |
2 | REPEATABLE_READ | Ëɤ²¤ë | Ëɤ²¤ë | ȯÀ¸ |
3 | SERIALIZABLE | Ëɤ²¤ë | Ëɤ²¤ë | Ëɤ²¤ë |
| tx1À®¸ù tx2À®¸ù | ----------->| ----------->| ------X | ¥·¥¹¥Æ¥à¾ã³²È¯À¸ ¥Á¥§¥Ã¥¯¥Ý¥¤¥ó¥È (¸½¾õ)
# | ¼ç¥µ¥¤¥È | (ÄÌ¿®) | ½¾¥µ¥¤¥È1 | ½¾¥µ¥¤¥È2 |
1 | ½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥ÈÍ×µá | ¥³¥ß¥Ã¥È | ||
2 | ½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥ÈÍ×µá | ¥³¥ß¥Ã¥È |
# | ¼ç¥µ¥¤¥È | (ÄÌ¿®) | ½¾¥µ¥¤¥È1 | ½¾¥µ¥¤¥È2 |
1 | ½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥È½àÈ÷Í×µá | ¥»¥¥å¥¢¾õÂÖ | ||
2 | ½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥È½àÈ÷Í×µá | ¥»¥¥å¥¢¾õÂÖ | ||
3 | ½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥ÈÍ×µá | ¥³¥ß¥Ã¥È | ||
4 | ½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥ÈÍ×µá | ¥³¥ß¥Ã¥È |
# | ¼ç¥µ¥¤¥È | (ÄÌ¿®) | ½¾¥µ¥¤¥È1 | ½¾¥µ¥¤¥È2 |
1 | ½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥È½àÈ÷Í×µá | ¥»¥¥å¥¢¾õÂÖ | ||
2 | ½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥È½àÈ÷Í×µá | ¥»¥¥å¥¢¾õÂÖ | ||
3 | ½¾¥µ¥¤¥È1¤Ë¥×¥ê¥³¥ß¥Ã¥ÈÍ×µá | (¤Ê¤Ë¤â¤·¤Ê¤¤) | ||
4 | ½¾¥µ¥¤¥È2¤Ë¥×¥ê¥³¥ß¥Ã¥ÈÍ×µá | (¤Ê¤Ë¤â¤·¤Ê¤¤) | ||
3 | ½¾¥µ¥¤¥È1¤Ë¥³¥ß¥Ã¥ÈÍ×µá | ¥³¥ß¥Ã¥È | ||
4 | ½¾¥µ¥¤¥È2¤Ë¥³¥ß¥Ã¥ÈÍ×µá | ¥³¥ß¥Ã¥È |
CREATE INDEX ½¾¶È°÷ŽÃŽ°ŽÌŽÞŽÙINDEXɽ ON ½¾¶È°÷ŽÃŽ°ŽÌŽÞŽÙ (name(10)) ̾Á°¤ÎºÇ½é10ʸ»ú¤Ç¥¤¥ó¥Ç¥Ã¥¯¥¹É½¤òºî¤ë
°ìÈ̤ÎHashɽ Hash¥¡¼ HashÃÍ 0001 AAAAA 0002 BBBBB 0003 CCCCC ¥Á¥§¥¤¥Ë¥ó¥°Ë¡ Hash¥¡¼ HashÃͤΥꥹ¥È 0001 AAAAA,AAAAB,AAAAC 0002 BBBBB,BBBBC,BBBBD 0003 CCCCC,CCCCD,CCCCE
Àµµ¬·Á | ¥Æ¡¼¥Ö¥ëÆâ¤Î°À¤òÁ´¤Æñ½ã°À¤Ë¤¹¤ë | ¥Æ¡¼¥Ö¥ëÆâ¤Î¥¡¼¹àÌܤËÂФ¹¤ëÉôʬ´Ø¿ô½¾Â°¤òºï½ü | ¥Æ¡¼¥Ö¥ëÆâ¤Î¿ä°ÜŪ´Ø¿ô½¾Â°¤òºï½ü |
ÈóÀµµ¬·Á | ¡ß | ¡ß | ¡ß |
Âè°ìÀµµ¬·Á | ¡û | ¡ß | ¡ß |
ÂèÆóÀµµ¬·Á | ¡û | ¡û | ¡ß |
Âè»°Àµµ¬·Á | ¡û | ¡û | ¡û |
----------------------------------------------------------------------------- ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ1 ¾¦ÉÊ̾1 ñ²Á1 ¾¦ÉÊÈÖ¹æ2 ¾¦ÉÊ̾2 ñ²Á2 ¾¦ÉÊÈÖ¹æ3 ¾¦ÉÊ̾3 ñ²Á3 ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¼õÃíÈÖ¹æ) ----------------------------------------------------------------------------- ¢ ----------------------------------------------------------------------------- ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ) -----------------------------------------------------------------------------
----------------------------------------------------------------------------- ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á ¾®·× ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ) ----------------------------------------------------------------------------- ¢ ----------------------------------------------------------------------------- ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¿ôÎÌ ¾®·× ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ) ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á PK(¾¦ÉÊÈÖ¹æ) -----------------------------------------------------------------------------
----------------------------------------------------------------------------- ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¿ôÎÌ ¾®·× ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ) ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á PK(¾¦ÉÊÈÖ¹æ) ----------------------------------------------------------------------------- ¢ ----------------------------------------------------------------------------- ¼õÃíÈÖ¹æ ¾¦ÉÊÈÖ¹æ ¿ôÎÌ ¸ÜµÒÈÖ¹æ ¢¨¾®·×¤òºï½ü PK(¼õÃíÈÖ¹æ,¾¦ÉÊÈÖ¹æ) ¾¦ÉÊÈÖ¹æ ¾¦ÉÊ̾ ñ²Á PK(¾¦ÉÊÈÖ¹æ) ¸ÜµÒÈÖ¹æ ¸ÜµÒ̾ ¸ÜµÒ½»½ê PK(¸ÜµÒÈÖ¹æ) -----------------------------------------------------------------------------
id | °ÀX | °ÀY | °ÀZ |
t1 | 1 | a | A |
t2 | 1 | a | B |
t3 | 1 | b | A |
t4 | 1 | b | B |
----------------------------------------------------------------------------- ¾¦ÉʼïÊÌ ¾¦ÉÊ̾ À½Â¤¸µ PK(¾¦ÉÊÈÖ¹æ) // ¥Ü¥¤¥¹¥´¥Ã¥ÈÀµµ¬²½ºÑ¤ß ----------------------------------------------------------------------------- ¢ ----------------------------------------------------------------------------- ¾¦ÉʼïÊÌ ¾¦ÉÊ̾ PK(¾¦ÉʼïÊÌ) ¾¦ÉʼïÊÌ À½Â¤¸µ PK(¾¦ÉʼïÊÌ) -----------------------------------------------------------------------------
----------------------------------------------------------------------------- ²·ÀèŹ ¾¦ÉʼïÊÌ À½Â¤¸µ¥á¡¼¥«¡¼(PK ²·ÀèŹ,¾¦ÉʼïÊÌ,À½Â¤¸µ) ----------------------------------------------------------------------------- ¢ ----------------------------------------------------------------------------- ²·ÀèŹ ¾¦ÉʼïÊÌ (PK ²·ÀèŹ,¾¦ÉʼïÊÌ) ²·ÀèŹ À½Â¤¸µ¥á¡¼¥«¡¼ (PK ²·ÀèŹ,À½Â¤¸µ) ¾¦ÉʼïÊÌ À½Â¤¸µ¥á¡¼¥«¡¼ (PK ¾¦ÉʼïÊÌ,À½Â¤¸µ) -----------------------------------------------------------------------------
Y ¢¾ X ¤Î¤È¤¡¢X->Y¤¬¾ï¤ËÀ®Î©¤¹¤ë¤³¤È ex. X : ¾¦ÉÊÈÖ¹æ Y : ¾¦ÉÊÈֹ桢¾¦ÉÊ̾¡¢Ã±²Á
CREATE SCHEMA ¥¹¥¡¼¥Þ̾ AUTHORIZATION ¥æ¡¼¥¶
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 )
NO ACTION | ²¿¤â¤·¤Ê¤¤¡£FOREIGN KEY°À¤ËON¡Á¤ò½ñ¤«¤Ê¤¤¤È¤³¤ì¤¬ÀßÄꤵ¤ì¤ë |
CASCADE | ¥ì¥³¡¼¥É¤òºï½ü¤¹¤ë |
SET NULL | ³°Éô»²¾ÈÎó¤ËNULL¤ò¥»¥Ã¥È |
SET DEFAULT | ³°Éô»²¾ÈÎó¤Ë¥Ç¥Õ¥©¥ë¥ÈÃͤò¥»¥Ã¥È |
NO ACTION | ²¿¤â¤·¤Ê¤¤¡£FOREIGN KEY°À¤ËON¡Á¤ò½ñ¤«¤Ê¤¤¤È¤³¤ì¤¬ÀßÄꤵ¤ì¤ë |
CASCADE | ³°Éô»²¾ÈÎó¤ò¹¹¿·¤¹¤ë |
SET NULL | ³°Éô»²¾ÈÎó¤ËNULL¤ò¥»¥Ã¥È |
SET DEFAULT | ³°Éô»²¾ÈÎó¤Ë¥Ç¥Õ¥©¥ë¥ÈÃͤò¥»¥Ã¥È |
CREATE ASSERTION USER_TBL CHECK( AGE>18 AND AGE<30 )
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
¸¢¸Â | ¤Ç¤¤ë¤³¤È |
ALL PRIVILEGES | Á´Éô |
SELECT | SELECT |
INSERT | INSERT |
DELETE | DELETE |
UPDATE | UPDATE |
SELECT ¾¦ÉÊÈÖ¹æ , Àµ²Á FROM ¼õÃí¥Æ¡¼¥Ö¥ë
SELECT COUNT(*) FROM ¼õÃí¥Æ¡¼¥Ö¥ë
SELECT ¾¦ÉÊÈÖ¹æ , Àµ²Á , Àµ²Á*1.05 AS ÀÁµá³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë
SELECT '¾¦ÉÊÈÖ¹æ='|| ¾¦ÉÊÈÖ¹æ , 'Àµ²Á='|| Àµ²Á , 'ÀÁµá³Û='|| Àµ²Á*1.05 AS ÀÁµá³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë
SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ¸ÜµÒID='00456'
SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ǼÉÊÀè½»½ê IS NULL
SELECT DISTINCT ¾¦ÉÊÈÖ¹æ FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ¸ÜµÒID='00456'
SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ¼õÃíÆü BETWEEN '2000-01-01' AND '2004-12-31'
(eq.) SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ¼õÃíÆü >= '2000-01-01' AND ¼õÃíÆü <='2004-12-31'
SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ¼õÃíÆü IN('2003-11-10','2003-11-11')
SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ¼õÃíÆü IN( SELECT Æü»þ FROM ÆüÉÕ¥Þ¥¹¥¿ WHERE Æü»þ°À='µÙ¶È' )
SELECT * FROM ¼õÃí¥Æ¡¼¥Ö¥ë X WHERE EXISTS( SELECT * FROM ÆüÉÕ¥Þ¥¹¥¿ Y WHERE X.¼õÃíÆü = Y.ÆüÉÕ AND Y.Æü»þ°À='µÙ¶È' )
1·ï°Ê¾å¤Î¼õÃí¤¬¤¢¤Ã¤¿Æü¤Î¼õÃí¶â³Û¤Î¹ç·× SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü HAVING COUNT(*) > 0
SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü ORDER BY ¼õÃíÆü // ¾Êά»þ¤ÏASC
SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü ORDER BY ¼õÃíÆü ASC
SELECT ¼õÃíÆü,SUM(¼õÃí¶â³Û) AS ¹ç·×¼õÃí¶â³Û FROM ¼õÃí¥Æ¡¼¥Ö¥ë GROUP BY ¼õÃíÆü ORDER BY 2 DESCORDER BY¤Î¸å¤ËSQL´Ø¿ô¤ò½ñ¤¯¤È¥¨¥é¡¼ ¢ª ¹Ô¿ô¤Ç»ØÄê
ID | PHRASE |
1 | ½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß |
2 | ½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î |
3 | ¤¢¤·¤Ó¤¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î |
4 | ÅĻҤαº¤Ë ¤¦¤Á½Ð¤Ç¤Æ¸«¤ì¤Ð Çò̯¤Î |
5 | ±ü»³¤Ë ¹ÈÍդդߤ櫓 ÌĤ¯¼¯¤Î |
ID | PHRASE |
1 | ²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä |
2 | °á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³ |
3 | ¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à |
6 | Çò¤¤ò¸«¤ì¤Ð Ì뤾¹¹¤±¤Ë¤±¤ë |
7 | »°³Þ¤Î»³¤Ë ½Ð¤Ç¤··î¤«¤â |
SELECT U.ID , U.PHRASE , L.PHRASE FROM UPPER_TBL U , LOWER_TBL L WHERE U.ID = L.ID
U.ID | U.PHRASE | L.PHRASE |
1 | ½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß | ²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä |
2 | ½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î | °á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³ |
3 | ¤¢¤·¤Ó¤¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î | ¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à |
SELECT U.ID , U.PHRASE , L.PHRASE FROM UPPER_TBL U FULL JOIN LOWER_TBL L ON U.ID = L.ID
U.ID | U.PHRASE | L.PHRASE |
1 | ½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß | ²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä |
2 | ½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î | °á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³ |
3 | ¤¢¤·¤Ó¤¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î | ¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à |
4 | ÅĻҤαº¤Ë ¤¦¤Á½Ð¤Ç¤Æ¸«¤ì¤Ð Çò̯¤Î | null |
5 | ±ü»³¤Ë ¹ÈÍդդߤ櫓 ÌĤ¯¼¯¤Î | null |
6 | null | Çò¤¤ò¸«¤ì¤Ð Ì뤾¹¹¤±¤Ë¤±¤ë |
7 | null | »°³Þ¤Î»³¤Ë ½Ð¤Ç¤··î¤«¤â |
SELECT U.ID , U.PHRASE , L.PHRASE FROM UPPER_TBL U LEFT JOIN LOWER_TBL L ON U.ID = L.ID
U.ID | U.PHRASE | L.PHRASE |
1 | ½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß | ²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä |
2 | ½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î | °á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³ |
3 | ¤¢¤·¤Ó¤¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î | ¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à |
4 | ÅĻҤαº¤Ë ¤¦¤Á½Ð¤Ç¤Æ¸«¤ì¤Ð Çò̯¤Î | null |
5 | ±ü»³¤Ë ¹ÈÍդդߤ櫓 ÌĤ¯¼¯¤Î | null |
SELECT L.ID , U.PHRASE , L.PHRASE FROM UPPER_TBL U RIGHT JOIN LOWER_TBL L ON U.ID = L.ID
L.ID | U.PHRASE | L.PHRASE |
1 | ½©¤ÎÅĤΠ¤«¤ê¤Û¤Î°Ã¤Î ÆѤò¤¢¤é¤ß | ²æ¤¬°á¼ê¤Ï Ϫ¤Ë¤Ì¤ì¤Ä¤Ä |
2 | ½Õ²á¤®¤Æ ²ÆÍè¤Ë¤±¤é¤· Çò̯¤Î | °á¤Û¤¹¤Æ¤Õ Å·¤Î¹á¶ñ»³ |
3 | ¤¢¤·¤Ó¤¤Î »³Ä»¤ÎÈø¤Î ¤·¤À¤êÈø¤Î | ¤Ê¤¬¤Ê¤¬¤·Ìë¤ò ¤Ò¤È¤ê¤«¤â¿²¤à |
6 | null | Çò¤¤ò¸«¤ì¤Ð Ì뤾¹¹¤±¤Ë¤±¤ë |
7 | null | »°³Þ¤Î»³¤Ë ½Ð¤Ç¤··î¤«¤â |
INSERT INTO ¼õÃí¥Æ¡¼¥Ö¥ë( ¼õÃíID ¸ÜµÒID, ¾¦ÉÊID, ¿ôÎÌ, ǼÉʎ̎׎¸ŽÞ, ¼õÃíÆü ǼÉÊÆü, ºï½üŽÌŽ×Ž¸ŽÞ) VALUES( '034564', '130576' 'J94045', 4, 0 '2005-03-31' null '0')
UPDATE ¼õÃí¥Æ¡¼¥Ö¥ë SET ǼÉʎ̎׎¸ŽÞ=1 , ǼÉÊÆü='2005-04-02' WHERE ¼õÃíID = '034564'
DELETE FROM ¼õÃí¥Æ¡¼¥Ö¥ë WHERE ºï½üŽÌŽ×Ž¸ŽÞ='1'