|
|
|
|
|
0 |
|
View Articles |
|
|
Name |
¼Õº´¸ñ |
(2002-05-05 18:22:36, Hit : 18399, Vote : 1828)
|
|
|
Homepage |
http://www.itmembers.net |
|
Subject |
DML(Data Manipulation Language) - INSERT |
|
|
Áö³ ½Ã°£¿¡ UPDATE ¹®¿¡ ´ëÇØ ¾Ë¾Æº¸¾Ò½À´Ï´Ù.
À̹ø ½Ã°£¿¡µµ ¿ª½Ã DMLÀÇ ÇϳªÀÎ INSERT ¹®¿¡ ´ëÇØ ¾Ë¾Æº¸±â·Î ÇÏ°Ú½À´Ï´Ù.
- INSERT¹®ÀÇ Çü½Ä°ú Ư¡
INSERT INTO table_name (column_one, column_two, ¡¦)
VALUES (expression_one, expression_two,¡¦);
- INTO ´ÙÀ½¿¡ ¿À´Â Å×ÀÌºí¿¡ VALUEÀÇ °ªÀ» »ðÀÔÇÏ´Â ¿ªÇÒÀ» ÇÕ´Ï´Ù.
À̶§ INTO Àý ´ÙÀ½¿¡ ±â¼úÇÏ´Â column¸íÀº »ý·«ÇÒ ¼ö ÀÖ½À´Ï´Ù.
- VALUES Àý¿¡´Â »ó¼ö(CONSTANT) °ª, ³Î(NULL) °ª, SYSDATE µîÀ» ¾µ ¼ö ÀÖ½À´Ï´Ù.
À§¿Í °°Àº CUSTOMER Å×ÀÌºí¿¡ ³ë¶õ »ö ºÎºÐ('104', 'À±Áö¼ö', µî·Ï³¯Â¥)ÀÇ µ¥ÀÌÅ͸¦ »ðÀÔÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ ¾¹´Ï´Ù.
INSERT INTO CUSTOMER ( CUST_NO, NAME, MILEAGE, CODE, REG_DATE)
VALUES ('104', 'À±Áö¼ö', NULL, NULL, SYSDATE);
¿©±â¼ ÁÖÀÇÇÒ °ÍÀº MILEAGE¿Í CODE¿¡´Â ¾Æ¹« °ªµµ ³ÖÁö ¾Ê¾Ò½À´Ï´Ù. ÀÌ·² ¶§ NULLÀ» »ç¿ëÇÕ´Ï´Ù.
±×¸®°í REG_DATE¿¡´Â À§ÀÇ µ¥ÀÌÅ͸¦ ÀÔ·ÂÇÑ ³¯Â¥¸¦ Áý¾î³Ö±â À§ÇØ SYSDATE¸¦ »ç¿ëÇÏ¿´½À´Ï´Ù.
- INSERT ¹®¿¡¼ SUBSELECT »ç¿ë
À§ÀÇ ¿¹´Â µ¥ÀÌÅ͸¦ Á÷Á¢ ÀÔ·ÂÇÒ °æ¿ì¿¡ ÇØ´çµÇ´Â °ÍÀÔ´Ï´Ù.
¸¸¾à µ¥ÀÌÅ͸¦ ÀԷ¹ÞÀ» Å×À̺íÀÌ ÀÖÀ» °æ¿ì ÀÌ Å×À̺íÀÇ ¾î¶² °ªÀ» ´Ù¸¥ Å×À̺í·Î ÀÔ·ÂÇÒ °æ¿ì¿¡´Â ¾î¶»°Ô ÇÒ±î¿ä?
¹Ù·Î VALUE Àý¿¡ SELECT ¹®À» ÀÌ¿ëÇÏ¿© Á¶°Ç¿¡ ¸Â´Â µ¥ÀÌÅ͸¦ °ñ¶ó ´Ù¸¥ Å×ÀÌºí¿¡ Á÷Á¢ ÀÔ·ÂÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
ÀÌ °æ¿ì µÎ Å×À̺íÀÇ Ä®·³ Çü½ÄÀº °°¾Æ¾ß µÇ°ÚÁÒ.
ÀÚ, ±×·³ ¾Æ·¡ COSTOMER Å×ÀÌºí¿¡¼ ¸¶Àϸ®Áö(MILEAGE)°¡ 10,000 ÀÌ»óÀÎ °í°´ Á¤º¸¸¦ VIP Å×ÀÌºí¿¡ ÀÔ·ÂÇÏ·Á¸é ¾î¶»°Ô ÇÒ±î¿ä?
¡é
INSERT INTO VIP
SELECT *
FROM CUSTOMER
WHERE MILEAGE >= 10000;
¿©±â¼ ÁÖÀÇÇؾßÇÒ °ÍÀº,
- SUBSELECT ¹®ÀÇ WHERE ÀýÀ» »ý·«Çϸé Å×À̺íÀÇ ¸ðµç µ¥ÀÌÅÍ°¡ ¹é¾÷µË´Ï´Ù.(ÀϺη¯ µ¥ÀÌÅ͸¦ ¹é¾÷ÇÒ ¶§ ÀÌ·± ½ÄÀ¸·Î »ç¿ëÇÕ´Ï´Ù.)
- INSERT ¹®¿¡¼ SUBSELECT¸¦ ¾µ °æ¿ì VALUES¿Í ( )¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.
ÀÌ»ó µ¿ÁÖ ¾Æºü ¼Õº´¸ñÀ̾ú½À´Ï´Ù.
|
|
|
|
|
|