Oracle 9i ÊÂÎñ´¦Àí

80¿á¿áÍø    80kuku.com

¡¡¡¡   ÊÂÎñÊÇOracle 9iÖнøÐÐÊý¾Ý¿â²Ù×÷µÄ»ù±¾µ¥Î»£¬ÔÚPL/SQL³ÌÐòÖУ¬¿ÉÒÔʹÓÃ3¸öÊÂÎñ´¦Àí¿ØÖÆÃüÁî¡£

commitÃüÁî

    commitÊÇÊÂÎñÌá½»ÃüÁî¡£ÔÚOracle 9iÊý¾Ý¿âÖУ¬ÎªÁ˱£Ö¤Êý¾ÝµÄÒ»ÖÂÐÔ£¬ÔÚÄÚ´æÖн«ÎªÃ¿¸ö¿Í»§»ú½¨Á¢¹¤×÷Çø£¬¿Í»§»ú¶ÔÊý¾Ý¿â½øÐвÙ×÷´¦ÀíµÄÊÂÎñ¶¼ÔÚ¹¤×÷ÇøÄÚÍê³É£¬Ö»ÓÐÔÚÊäÈëcommitÃüÁîºó£¬¹¤×÷ÇøÄÚµÄÐÞ¸ÄÄÚÈݲÅдÈëµ½Êý¾Ý¿âÉÏ£¬³ÆΪÎïÀíдÈ룬ÕâÑù¿ÉÒÔ±£Ö¤ÔÚÈÎÒâµÄ¿Í»§»úûÓÐÎïÀíÌá½»ÐÞ¸ÄÒÔÇ°£¬±ðµÄ¿Í»§»ú¶ÁÈ¡µÄºǫ́Êý¾Ý¿âÖеÄÊý¾ÝÊÇÍêÕûµÄ¡¢Ò»Öµģ¬Èçͼ9.26Ëùʾ¡£

    ÔÚ¡¾SQLPlus Worksheet¡¿ÖпÉÒÔÖ´ÐÐÏÂÁÐPL/SQL³ÌÐò´ò¿ª×Ô¶¯Ìá½»¹¦ÄÜ¡£ÕâÑùÿ´ÎÖ´ÐÐPL/SQL³ÌÐò¶¼»á×Ô¶¯½øÐÐÊÂÎñÌá½»¡£Ö´Ðнá¹ûÈçͼ9.27Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    set auto on;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\setautocommiton.sql¡£

    ÏàÓ¦µÄ£¬È¡Ïû×Ô¶¯Ìá½»¹¦ÄܵÄPL/SQL³ÌÐòÈçÏ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    set auto off;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\setautocommitoff.sql¡£

rollbackÃüÁî

    ollbackÊÇÊÂÎñ»Ø¹öÃüÁÔÚÉÐδÌá½»commitÃüÁî֮ǰ£¬Èç¹û·¢ÏÖdelete¡¢insertºÍupdateµÈ²Ù×÷ÐèÒª»Ö¸´µÄ»°£¬¿ÉÒÔʹÓÃrollbackÃüÁî»Ø¹öµ½ÉÏ´ÎcommitʱµÄ״̬¡£
    ÏÂÃæÒÔdeleteÃüÁîΪÀýÑÝʾÈçºÎ»Ø¹ö¡£
    £¨1£©Ê×ÏȹرÕ×Ô¶¯Ìá½»¹¦ÄÜ¡£
    £¨2£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÏÂÁÐSQL³ÌÐò£¬²é¿´scott.empÊý¾Ý±íÖеÄËùÓÐÊý¾Ý£¬Ö´Ðнá¹ûÈçͼ9.28Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    select * from scott.emp;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\selectemp.sql¡£

    £¨3£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÏÂÁÐSQL³ÌÐò£¬É¾³ýscott.empÊý¾Ý±íÖеÄËùÓÐÊý¾Ý¡£Ö´Ðнá¹ûÈçͼ9.29Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    delete from scott.emp;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\deleteemp.sql¡£

    £¨4£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÏÂÁÐSQL³ÌÐò£¬²éѯɾ³ýÊý¾Ý±íscott.empºóµÄ½á¹û¡£Ö´Ðнá¹ûÈçͼ9.30Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    select * from scott.emp;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\selectemp.sql¡£

    £¨5£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÒÔÏÂSQL³ÌÐò£¬Íê³ÉÊÂÎñµÄ»Ø¹ö¡£Ö´Ðнá¹ûÈçͼ9.31Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    rollback;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\rollbackemp.sql¡£

    £¨5£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐselectemp.sqlÎļþ£¬Ö´Ðнá¹ûÈçͼ9.28Ëùʾ£¬±íÃ÷³É¹¦»Ø¹öÁËÊÂÎñ¡£

savepointÃüÁî

    savepointÊDZ£´æµãÃüÁî¡£ÊÂÎñͨ³£ÓÉÊýÌõÃüÁî×é³É£¬¿ÉÒÔ½«Ã¿¸öÊÂÎñ»®·Ö³ÉÈô¸É¸ö²¿·Ö½øÐб£´æ£¬ÕâÑùÿ´Î¿ÉÒԻعöÿ¸ö±£´æµã£¬¶ø²»±Ø»Ø¹öÕû¸öÊÂÎñ¡£Óï·¨¸ñʽÈçÏ¡£
    ´´½¨±£´æµã£ºsavepoint ±£´æµãÃû;
    »Ø¹ö±£´æµã£ºrollback to ±£´æµãÃû;
    ÏÂÃæ½éÉÜÈçºÎʹÓñ£´æµã¡£
    £¨1£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÒÔÏÂSQL³ÌÐò£¬³ÌÐòÍê³ÉÏòscott.empÊý¾Ý±íÖвåÈëÒ»Ìõ¼Ç¼¡£Ö´Ðнá¹ûÈçͼ9.32Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    insert into scott.emp(empno,ename,sal) values(9000,'wang',2500);
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\insertemp.sql¡£

    £¨2£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÏÂÁÐSQL´úÂ룬Íê³É´´½¨±£´æµãµÄ²Ù×÷¡£Ö´Ðнá¹ûÈçͼ9.33Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    savepoint insertpoint;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\ createsavepoint.sql¡£

    £¨3£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖпÉÒÔÖ´ÐÐÆäËûµÄSQLÓï¾ä¡£
    £¨4£©ÔÚ¡¾SQLPlus Worksheet¡¿ÖÐÖ´ÐÐÏÂÁÐSQL´úÂ룬³ÌÐòÍê³É»Ø¹öµ½Ö¸¶¨µÄ±£´æµã¡°insertpoint¡±¡£Ö´Ðнá¹ûÈçͼ9.34Ëùʾ¡£
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    rollback to insertpoint;
    ¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D¨D
    ¡¾ÅäÌ׳ÌÐòλÖá¿£ºµÚ9ÕÂ\ rollbacksavepoint.sql¡£

    £¨5£©¿ÉÒÔÖ´ÐÐselectemp.sqlÎļþ£¬²éѯ»Ø¹öÇ°ºóµÄÊý¾Ý¡£


·ÖÏíµ½
  • ΢ÐÅ·ÖÏí
  • ÐÂÀË΢²©
  • QQºÃÓÑ
  • QQ¿Õ¼ä

ÉÏһƪPL/SQLÁ÷³Ì¿ØÖÆ

ÏÂһƪOracle 9i Óαê

µã»÷£º