²Ä¤C³¹ ²ßÃD [ ²ßÃD7-1 ] ¦Ò¼{¥H¤Uªº¬d¸ß¡G SELECT tNo, COUNT(pNo) FROM (Transaction NATURAL JOIN Record) NATURAL JOIN Product WHERE method = ¡¥cart¡¦ AND unitPrice > 500 GROUP BY tNo HAVING COUNT(pNo) > 2; ½Ð¸ÑÄÀ¥H¤W¬d¸ß¥yªº·N¸q¡A¥¦©M¥»³¹Q20¦³¦ó¤£¦P¡H [ ²ßÃD7-2 ] °Ñ¦Ò¹Ï6-1ªº¸ê®Æ®wºõ¥Ø¡A
¨Ã«öÃD·N¦C¥X SQL ¬d¸ß¥y 1.
¦C¥X©~¦í©ó¥x¥_¿¤¥B¨S¦³¤¶²Ð¹L¨ä¥L·|ûªº·|û¤§·|û½s¸¹©M©m¦W¡C 2.
¦C¥X¨S¦³³QÁʶR¹Lªº®ÑÄy¤§°Ó«~½s¸¹©M¦WºÙ¡C 3.
¦C¥X¦b2004¦~±q¥¼³QÂsÄý¹L¤]±q¥¼³Q¶R¹Lªº©Ò¦³°Ó«~¤§°Ó«~½s¸¹ ©M¦WºÙ¡C 4.
½Ð¦C¥XJenny©ÒÂsÄý¹L¦ý¥¼ÁʶRªº°Ó«~¤§°Ó«~½s¸¹©M¦WºÙ¡C 5. ¦C¥XÂsÄý¹L¦ý¨SÁʶR¹L¡¦½²¨ÌªL±M¿è¤G¡¦ªº·|û¤§·|û½s¸¹©M©m¦W¡C [ ²ßÃD7-3 ] °Ñ¦Ò¹Ï6-1ªº¸ê®Æ®wºõ¥Ø¡A
¨Ã«öÃD·N¦C¥X SQL ¬d¸ß¥y¡G 1. ½Ð²£¥Í¤@Ó¦W¬°Trans2005ªºVIEW¡A¦C¥X2005¦~³QÁʶRªº¨C¥ó°Ó«~¤§°Ó«~½s¸¹,¦WºÙ,ºØÃþ¡AÁʶRÁ`¼Æ¶q¡AÁʶRÁ`ª÷ÃB¡C¨S¦³³QÁʶRªº¤£¥Î¦C¥X¡C 2. ½Ð®Ú¾ÚTrans2005¡A§ä¥X¦b2005¦~³QÁʶRªº¨C¥ó®ÑÄy¤§°Ó«~½s¸¹,¦WºÙ¤ÎÁʶRÁ`¼Æ¶q¡C 3.
½Ð®Ú¾ÚTrans2005¡A§ä¥X2005¦~ªº®ÑÄyÁ`ÁʶRª÷ÃB¡C 4. ½Ð®Ú¾ÚTrans2005©M¨ä¥L¸ê®Æªí¡A§ä¥X¦b2005¦~ùس£¨S¦³³QÁʶR¹Lªº°Ó«~¡C¨ä¤¤¥]¬A°Ó«~½s¸¹¡A¦WºÙ¡A³Ð§@ªÌ¤Î©w»ù¡C
[ ²ßÃD7-4 ] °Ñ¦Ò¹Ï6-1ªº¸ê®Æ®wºõ¥Ø¡A ¨Ã«öÃD·N¦C¥X SQL ¬d¸ß¥y
1.
¦C¥X¨C¤@°Ó«~¤§½s¸¹¡A¦WºÙ¡A©w»ù¡A©M³Ð§@ªÌ¤H¼Æ¡A½Ðª`·N¨S¦³³Ð§@ªÌªº°Ó«~¸ê°T¤]n¦C¥X¡C
2.
¦C¥X¨C¤@¤k©Ê·|û¡]¨¤ÀÃÒªº²Ä¤G½X¬°2¡^ªº·|û½s¸¹¡A©m¦W¡A©MÁʶRÁ`ª÷ÃB¡C
3.
¦C¥X2004¦~2¤ëªºÁ`¥æ©öª÷ÃB¡C
4.
²£¥Í¤@Ó¦W¬°MalePurchaseªºVIEW¡A¦C¥X¨k©Ê·|û¹ï©ó¨C¤@Ãþ°Ó«~¦b2004¦~ªºÁʶRÁ`ª÷ÃB¡C¡]´£¥Ü¡G¥ÑpIdªº²Ä¤GÓ¦r¤¸¥i¬Ý¥X©Ê§O¡X1¬°¨k©Ê2¬°¤k©Ê¡^ 5. ®Ú¾ÚMalePurchaseªºVIEW¡A¦C¥X¨k©Ê·|û¦b2004¦~ÁʶR®ÑÄyÃþ°Ó«~ªºÁ`ª÷ÃB¡C 6.
²£¥Í¤@Ó¦W¬°BrowseInfªºVIEW¡A¥]¬AÄæ¦ì·|û½s¸¹¡A·|û©m¦W¡A¨äÂsÄý®É¶¡¡A©M©ÒÂsÄýªº°Ó«~¦WºÙ¡C 7. ±N²Ä6¤pÃDªºVIEW±ÂÅvµ¹syhwang¬d¸ß¦ý¤£¥iÂಾ±ÂÅv¡C 8. §Q¥Î²Ä6¤pÃDªºVIEW©M¨ä¥L¸ê®Æªí¡A¦C¥X¨C¤@¦ì¤k©Ê·|ûªº©m¦W¡A©M¨ä¦b2004¦~10¤ë¥÷ÂsÄý¨C¤@¥ó°Ó«~ªº¦¸¼Æ¡C 9.
±N2004¦~10¤ë¥÷¾P°âÁ`ª÷ÃB¶W¹L100,000ªº°Ó«~©w»ù´£°ª¤@¦¨¡C 10. ¦C¥XÁʶR¹L©Ò¦³¡u®]¿P«º¡vCD¡]®]¿P«º¬°³Ð§@ªÌ¡^ªº·|û¤§·|û½s¸¹©M©m¦W¡C 11.
¹ï©ó¨C¤@¦b2004¦~10¤ë¥÷³Q¶W¹L100¦ì·|ûÂsÄýªº°Ó«~¡A¦C¥X¨ä°Ó«~½s¸¹¡A°Ó«~¦WºÙ¡A©M¨ä¦b2004¦~10¤ë¥÷ªº¾P°âÁ`ª÷ÃB¡C
[ ²ßÃD7-5 ] °Ñ¦Ò¹Ï6-1ªº¸ê®Æ®wºõ¥Ø¡A ¨Ã«öÃD·N¦C¥X SQL ¬d¸ß¥y
1.
§ä¥X¦³ÁʶR¹L½s¸¹¬°¡¥a0910001¡¦ªº·|û©ÒÁʶR¹Lªº©Ò¦³°Ó«~ªº·|û¤§·|û½s¸¹©M©m¦W¡C
2.
¹ï©ó¨C¤@µ§¥æ©öÁ`ª÷ÃB¶W¹L1,000ªº¥æ©ö¡A¦C¥X¨ä¥æ©ö½s¸¹©M©ÒÁʶRªº°Ó«~ºØ¼Ë¼Æ¡C
3.
½Ð§ä¥X2005¦~10¤ë¥÷¨C¤@·|ûªº¥æ©öÁ`ª÷ÃB¡A¦C¥X·|û½s¸¹¡A©m¦W¡A ¥æ©öÁ`ª÷ÃB¡C½Ðª`·N¨S¦³¥æ©öªº·|û¤]»Ý¦C¥X¡A¨ä¥æ©öÁ`ª÷ÃB«h¬°0¡C
4.
¹ï©ó¨C¤@¼g®Ñ¶W¹L5¥»¥H¤Wªº§@ªÌ¡£¥ÑAuthor¸ê®Æªí±oª¾¡A¨Ã°²³]§@ªÌ©m¦W¬°°ß¤@¡¤¡A¦C¥X¨ä©m¦W©M2005¦~10¤ë¥÷¾P°â®ÑÄyªºÁ`ª÷ÃB¡C
[ ²ßÃD7-6 ] °Ñ¦Ò¹Ï6-1ªº¸ê®Æ®wºõ¥Ø¡A ¨Ã«öÃD·N¦C¥X SQL ¬d¸ß±Ôz
1.
1. ½Ð±NMember ¸ê®Æªí¸Ì¥[¤J¤@Ó«¬ºA¬°VARCHAR¡]30¡^ªºÄÝ©Êurl¡A¨ÃקïÄݩʦWºÙaddress¬°mailing_add¡C
2.
½Ð¥ÎCREATE ASSERTION¨Óªí¹F¥H¤U¸ê®Æ¨î¡G¨C¤@¥»®Ñ¡]¤]´N¬Ocatalog=¡¦Book¡¦ªº°Ó«~¡^¦Ü¤Ö»Ý¦³¤@¦ì§@ªÌ¡C
3.
2. §ä¥X¦b2005¦~ÁʶR°ª³æ»ù°Ó«~¡]°²³]¶W¹L1000¤¸ªº°Ó«~ºÙ¬°°ª³æ»ù°Ó«~¡^¶W¹L5¥óªº·|û¤§·|û½s¸¹¡A©m¦W©M¨ä2005¦~ªº¥æ©öÁ`ª÷ÃB¡C
[ ²ßÃD7-7 ] ¦Ò¼{ [²ßÃD4-6] »·¶Z±Ð¾Çªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G ¦C¥Xס¨¸ê®Æ®wºÞ²z¡¨ªº¨C¦ì¦P¾Çªº¾Ç¸¹©M±i¶K½g¼Æ¡C [ ²ßÃD7-8 ] ¦Ò¼{ [²ßÃD4-8]
¾´ÎÁp·ù¾ÔÁZªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G 1. ¦C¥X' New York Yankees'Á`¦@Ĺ´X³õ©M¿é´X³õ¡C 2. §ä¥X¡¦American League¡¦ªº±`³Óx¡]§Y¨º¨Ç¦b¸ÓÁp·ù¥B±q¥¼³Q¥´±Ñªº²y¶¤¦WºÙ¡^¡C 3. ¹ï©ó¨C¤@²yû¶W¹L15¤Hªº²y¶¤¡A¦C¥X¨ä²y¶¤¦WºÙ©M¤ëÁ~¶W¹L10¸U¤¸ªº²yû¼Æ¡C [ ²ßÃD7-9 ] ¦Ò¼{ [²ßÃD4-9]
¤p«¬¤u¼tªº®w¦s¨t²Îªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G 1. ¹ï©ó¨C¤@¨ÑÀ³100ºØ¥H¤Wª«®Æªº¨ÑÀ³°Ó¡A¦C¥X¸Ó¨ÑÀ³°Ó¤½¥q¦WºÙ©M¨ä2000¦~11¤ë¥÷ªº¶i®ÆºØÃþ¼Æ¡C 2. §ä¥X¤OÅQ¾T±ø¦b2000¦~10¤ëªºÁ`¶i®Æ¶q¡C 3. ¹ï©ó¨C¤@¦b2000¦~10¤ëªºÁ`¶i®Æ¶q¶W¹L20000ªºª«®Æ¡A¦C¥X¨ä¦WºÙ©M¨ä¦b2000¦~10¤ë¥÷ªºÁ`»â®Æ¶q¡C [ ²ßÃD7-10 ] ¦Ò¼{ [²ßÃD4-10] ¿ý¼v±a¯²É¨t²Îªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G
1.
¦C¥X§õ¦w©Ò¾Éºtªº¦U¼v¤ùºØÃþªºÁ`¤ù¼Æ¡C
2.
±N¡¨ª×ªêÂÃÀs¡¨(¬°¤@¤ù¦W)«ö¦U´CÅé(VCR, DVD, VCD, etc)¦C¥X¨ä«þ¨©¼Æ¶q¡C
3.
±N¨C¤@¼v¤ù¼Æ¶W¹L100ªº¼v¤ùºØÃþ¡A¦C¥X¨ä¦WºÙ©Mµ¥¯Å¬°'PG-13'ªº¤ù¼Æ¡C
[ ²ßÃD7-11 ] ¦Ò¼{ [²ßÃD4-11] °Ý¨÷½Õ¬d¨t²Îªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G
1.
¹ï©ó¨C¤@°Ý¨÷¡A¦C¥X¨ätitle©Mvisible='Y'ªº³æ¿ïÃDªºÃD¼Æ¡C
2.
¹ï©ó¨C¤@¦b2001¦~³Q¶ñ¼gªº¦¸¼Æ¶W¹L50¦¸ªº°Ý¨÷¡A¦C¥X¨ätitle©M³æ¿ïÃDªºÃD¼Æ¡C [ ²ßÃD7-12 ] ¦Ò¼{ [²ßÃD4-12] ©ç½æºô¯¸¨t²Îªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G
1.
¹ï©ó¤@mID='m0002', seqNo='003' ªº°Ó«~¡A¦C¥X¨ä©ç½æªÌ©m¦W¡B©³»ù¡B©M¥Ø«e³Ì°ª¥s»ù
2.
¹ï©ó¨C¤@·|û¡A¦C¥X¨ä¦b2002¦~11¤ëªºÁ`¥s»ù¦¸¼Æ©MÁ`¦¨¥æ¦¸¼Æ¡C [ ²ßÃD7-13 ] ¦Ò¼{ [²ßÃD4-14] À\ÆUÂIµæ¨t²Îªº¸ê®Æ®wºõ¥Ø ¡A
1.
¹ï©ó¨C¤@Ó®MÀ\¡A¦C¥X¨ä¦WºÙ¡B»ù¿ú¡B©M¨ä¦b 2004 ¦~ 11 ¤ë³QÂIªºÁ`¦¸¼Æ¡C½Ðª`·N¡A·í¤@®MÀ\§¹¥þ¨S¦³³QÂI®É¡A¤]n¦C¥X³o¨Ç¸ê°T¡C½Ð¥Î¤@Ó SQL ¬d¸ß¥yªí¹F¡C
2.
¹ï©ó¨C¤@ӥѤTºØ¥H¤W³æÂI©Ò²Õ¦¨ªº®MÀ\¡A¦C¥X¨ä¦WºÙ¡B»ù¿ú¡B©M¨ä¦b 2004 ¦~ 11 ¤ë³QÂIªºÁ`¦¸¼Æ¡C½Ð¥Î¤@Ó SQL ¬d¸ß¥yªí¹F¡C
[ ²ßÃD7-14 ] ¦Ò¼{ [²ßÃD4-15] Âå°|±¾¸¹¨t²Îªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQLªí¹F¥X¥H¤Uªº¬d¸ß©Î¸ê®ÆºûÅ@¡C
1.
¦C¥X¤@¯ë¤º¬ìªºÂå®v¤§½s¸¹¡A©m¦W¡A©M¾¯Å¡A¦Ó¥B¦P¤@¾¯ÅªºÂå®vn±Æ¦b¤@°_¡C 2. ¹ï©ó¨C¤@¦ì¤@¯ë¤º¬ìÂå®v¡A¦C¥X¨ä½s¸¹¡A©m¦W¡B©M¦b2006¦~4¤ëªºÁ`±¾¸¹¤H¦¸¡C½Ðª`·N¨S¦³³Q±¾¸¹ªºÂå®v¸ê®Æ¤]¥²¶·¦C¥X¡A¦¹®É¨äÁ`±¾¸¹¤H¦¸¬°0¡C½Ð¥Î¤@ÓSQL¬d¸ß¥yªí¹F¡C 3.
½Ð¦C¥X¨C¤@¦ì¦b2005¦~±¾¸¹¹L©Ò¦³¤@¯ë¤º¬ìÂå®vªº¯f¤H¤§¯f¾ú¸¹¡A©m¦W¡A¥Í¤é¡A©M©Ê§O¡C½Ð¥Î¤@ÓSQL¬d¸ß¥yªí¹F¡C 4. ¹ï©ó¨C¤@ÓÂå®v¤H¼Æ¶W¹L10¤Hªº¬ì¡A¦C¥X¬ì¦W©M2006¦~4¤ëªº±¾¸¹Á`¤H¦¸¡C 5.
½Ð¥ÎSQL±Ôz²£¥Í¤@Ó¹êÅ骺¸ê®ÆªíDoctorPatients¡]dId, totalNum¡^¡A°O¸ü¨C¤@¦ìÂå®vªº½s¸¹©M¨äÁ`±¾¸¹¤H¦¸¡C 6. ½Ð²£¥Í¤@ÓTrigger¡A¨C¼W¥[¤@µ§¹w¬ù°O¿ý®É´N±NDoctorPatients¸Ì¸ÓÂå®vªºÁ`±¾¸¹¤H¦¸¥[1¡C
[ ²ßÃD7-15 ] ¦Ò¼{ [²ßÃD4-16]
¥xÆWÁ`²Î¿ïÁ|¥Á½Õªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G ¦C¥X¨C¤@¦ìÁ`²ÎÔ¿ï¤H¤§µn°O¸¹¡A©m¦W¡A©M¥Á½Õ±o²¼¼Æ¡C
[ ²ßÃD7-16 ] ¦Ò¼{ [²ßÃD4-17]
·s®Ñ±ÀÂ˨t²Îªº¸ê®Æ®wºõ¥Ø¡A½Ð¥ÎSQL¬d¸ß¥yªí¹F¥H¤U¬d¸ß¡G 1.
¹ï©ó¨C¤@Ó¨t©Ò¡A¦C¥X¨t©Ò¦WºÙ©M¨äŪªÌ¼Æ¡C 2.
°²³]¤ÀÃþ¶¥¼h¥u¦³¤T¼h¡A§ä¥X±i¤T¡]ŪªÌ¦W¡^·P¿³½ìªº©Ò¦³®Ñ¦W¡C [
²ßÃD7-17 ] ½Ð°Ý¥H¤U¨âÓCREATE INDEX±Ôz¦³¦ó®t§O¡G CREATE INDEX
CatPrice_index CREATE INDEX
PriceCat_index |