|
|
|
|
|
0 |
|
View Articles |
|
|
Name |
¼Õº´¸ñ |
(2002-05-07 22:18:11, Hit : 17808, Vote : 1986)
|
|
|
Homepage |
http://www.itmembers.net |
|
Subject |
Æ®·£Àè¼Ç(Transaction) Control Language - COMMIT, ROLLBACK, SAVEPOINT |
|
|
µ¥ÀÌÅͺ£À̽º¿¡¼ Æ®·£Àè¼Ç(Transaction)À̶õ ³í¸®ÀûÀÎ ÀÏÀÇ ´ÜÀ§¸¦ ¸»ÇÕ´Ï´Ù. °³³äÀûÀ¸·Î ¼³¸íÇϱ⿡´Â Ãß»óÀûÀÌ°í ¸ðÈ£ÇÑ ¸éÀÌ ¸¹¾Æ ½Ç·Ê¸¦ µé¾î ¼³¸íÇÏ´Â ÆíÀÌ ÈξÀ ÀÌÇØÇϱ⿡ ºü¸¦ °ÍÀÔ´Ï´Ù.
¾Æ·¡ ±×¸²À» º¸¼¼¿ä.
»ç¿ëÀÚ°¡ INSERT ¹®À» »ç¿ëÇØ µ¥ÀÌÅ͸¦ »ðÀÔÇÏ°í, UPDATE ¹®À¸·Î µ¥ÀÌÅ͸¦ °»½ÅÇÏ°í, DELETE ¹®À¸·Î µ¥ÀÌÅ͸¦ »èÁ¦ÇÏ¿´´Ù°í ÇսôÙ. ¸¸¾à ÀÌ ¸ðµç °úÁ¤ÀÌ ¿À·ù¾øÀÌ ¼öÇàµÇ¾ú´Ù¸é Áö±Ý±îÁö ½ÇÇàÇÑ ¸ðµç ÀÛ¾÷À» '½ÇÁ¦·Î' ¼öÇàÇ϶ó´Â ¸í·ÉÀ» ³»¸± ¼ö Àִµ¥ ÀÌ ¶§ÀÇ ¸í·ÉÀÌ ¹Ù·Î 'COMMIT' ¸í·ÉÀÔ´Ï´Ù. 'COMMIT' ¸í·ÉÀ» ÁÖ±â Àü±îÁöÀÇ ¸ðµç ÀÛ¾÷Àº 'ROLLBACK' ¸í·ÉÀ¸·Î ¿ø»óÅ·ΠµÇµ¹¸± ¼ö ÀÖ´Â °ÍÀÔ´Ï´Ù.
¸¸¾à INSERT ÀÛ¾÷À» ÇÑ ´ÙÀ½ 'SAVEPOINT A'¶ó´Â ¸í·ÉÀ» ½ÇÇàÇÏ¿´´Ù¸é ³ªÁß¿¡ 'ROLLBACK A'¶ó´Â ¸í·ÉÀ» ÅëÇØ INSERT ÀÛ¾÷À» ÇÑ ±× À§Ä¡·Î µÇµ¹¾Æ ¿Ã ¼ö ÀÖ´Â °ÍÀÌÁÒ. ±× Àü¿¡ 'COMMIT' ¸í·ÉÀ» ½ÇÇàÇÏÁö ¾Ê¾Ò´Ù¸é ¸»ÀÔ´Ï´Ù.
ÀÌ¿Í °°ÀÌ COMMIT ¸í·ÉÀ¸·Î ÇϳªÀÇ ÀÛ¾÷ÀÌ ¼º°øÀûÀ¸·Î ³¡³µÀ» ¶§ ¿ì¸®´Â Æ®·£Àè¼ÇÀÌ ¼º°øÀûÀ¸·Î ¼öÇàµÇ¾ú´Ù°í ¸»ÇÕ´Ï´Ù.
Æ®·£Àè¼Ç Á¦¾î¸¦ À§ÇÑ ¸í·É¾î(Transaction Coltrol Language)¿¡´Â ´ÙÀ½°ú °°Àº °ÍµéÀÌ ÀÖ½À´Ï´Ù.
- COMMIT
- SAVEPOINT
- ROLLBACK
Çϳª Çϳª »ìÆ캼±î¿ä?
- COMMITÀº ÀúÀåµÇÁö ¾ÊÀº ¸ðµç µ¥ÀÌÅ͸¦ µ¥ÀÌÅͺ£À̽º¿¡ ÀúÀåÇÏ°í ÇöÀçÀÇ Æ®·£Àè¼ÇÀ» Á¾·áÇ϶ó´Â ¸í·ÉÀÔ´Ï´Ù.
- SAVEPOINT [À̸§]´Â ÇöÀç±îÁöÀÇ Æ®·£Àè¼ÇÀ» ƯÁ¤ À̸§À¸·Î ÁöÁ¤Ç϶ó´Â ¸í·ÉÀÔ´Ï´Ù.
- ROLLBACK [TO SAVEPOINT À̸§]ÀúÀåµÇÁö ¾ÊÀº ¸ðµç µ¥ÀÌÅÍ º¯°æ »çÇ×À» Ãë¼ÒÇÏ°í ÇöÀçÀÇ Æ®·£Àè¼ÇÀ» ³¡³»¶ó´Â ¸í·ÉÀÔ´Ï´Ù. ¸¸¾à ÀÌÀü¿¡ SAVEPOINT·Î ÁöÁ¤ÇÑ À̸§ÀÌ ÀÖÀ¸¸é ±× À§Ä¡±îÁö µÇµ¹¾Æ °©´Ï´Ù.
ÀÌ¿Í °°ÀÌ COMMIT ¶Ç´Â ROLLBACK ¸í·ÉÀ¸·Î Á÷Á¢ Æ®·£Àè¼ÇÀ» ¿Ï¼ºÇϰųª Ãë¼ÒÇÒ ¼öµµ ÀÖÁö¸¸,
´ÙÀ½°ú °°Àº °æ¿ì¿¡´Â ÀÚµ¿À¸·Î Æ®·£Àè¼ÇÀÌ Á¾·áµË´Ï´Ù.
- DDL(CREATE, ALTER, DROP) ¸í·É¾î¸¦ ½ÇÇàÇÒ ¶§
- DCL(GRANT, REVOKE) ¸í·É¾î¸¦ ½ÇÇàÇÒ ¶§
- Deadlock°°Àº ƯÁ¤ Error¸¦ ¸¸³¯ ¶§
- SQL*Plus¸¦ Á¾·áÇÒ ¶§
À§¿Í °°Àº °æ¿ì¿¡´Â COMMIT³ª ROLLBACK ¹®ÀÌ ¾ø¾îµµ Æ®·£Àè¼ÇÀÌ Á¾·áµË´Ï´Ù.
±×·³, Á¤¸®ÇÏ´Â Àǹ̷Π´ÙÀ½°ú °°ÀÌ ÀÛ¾÷À» ÇÒ °æ¿ì ¾î¶°ÇÑ °á°ú°¡ ³ªÅ¸³¯Áö Çѹø »ý°¢ÇØ º¸¼¼¿ä.
- SQL*Plus½ÃÀÛ
- SELECT * FROM EMP;
- UPDATE EMP
SET JOB_CODE = 'AA'
WHERE EMP_NUM = '10001';
- SAVEPOINT update_point;
- DELETE FROM EMP;
- ROLLBACK TO update_point;
- DELETE FROM EMP
WHERE JOB_CODE = 'SS';
- COMMIT;
- INSERT INTO CUSTOMER
VALUES ('103', ¼Õº´¸ñ , NULL, NULL, SYSDATE);
ÀÌ»ó µ¿ÁÖ ¾Æºü ¼Õº´¸ñÀ̾ú½À´Ï´Ù.
|
|
|
|
|
|