:meta-keywords: delete statement :meta-description: You can delete records in the table by using the DELETE statement. ****** DELETE ****** **DELETE** ë¬¸ì„ ì‚¬ìš©í•˜ì—¬ í…Œì´ë¸” ë‚´ì— ë ˆì½”ë“œë¥¼ ì‚ì œí• ìˆ˜ 있으며, :ref:`where-clause`\ ê³¼ 결합하여 ì‚ì œ ì¡°ê±´ì„ ëª…ì‹œí• ìˆ˜ 있다. í•˜ë‚˜ì˜ **DELETE** 문으로 하나 ì´ìƒì˜ í…Œì´ë¸”ì„ ì‚ì œí• ìˆ˜ 있다. :: <DELETE single table> DELETE [FROM] table_name [ WHERE <search_condition> ] [LIMIT row_count] <DELETE multiple tables FROM ...> DELETE table_name[, table_name] ... FROM <table_specifications> [ WHERE <search_condition> ] <DELETE FROM multiple tables USING ...> DELETE FROM table_name[, table_name] ... USING <table_specifications> [ WHERE <search_condition> ] * <*table_specifications*>: **SELECT** ë¬¸ì˜ **FROM** ì ˆê³¼ ê°™ì€ í˜•íƒœì˜ êµ¬ë¬¸ì„ ì§€ì •í• ìˆ˜ 있으며, 하나 ì´ìƒì˜ í…Œì´ë¸”ì„ ì§€ì •í• ìˆ˜ 있다. * *table_name*: ì‚ì œí• ë°ì´í„°ê°€ í¬í•¨ë˜ì–´ 있는 í…Œì´ë¸”ì˜ ì´ë¦„ì„ ì§€ì •í•œë‹¤. í…Œì´ë¸”ì˜ ê°œìˆ˜ê°€ í•œ ê°œì¼ ê²½ìš° ì•žì˜ **FROM** 키워드를 ìƒëžµí• 수 있다. * *search_condition*: :ref:`where-clause`\ ì„ ì´ìš©í•˜ì—¬ *search_condition*\ ì„ ë§Œì¡±í•˜ëŠ” ë°ì´í„°ë§Œ ì‚ì œí•œë‹¤. ìƒëžµí• 경우 ì§€ì •ëœ í…Œì´ë¸”ì˜ ëª¨ë“ ë°ì´í„°ë¥¼ ì‚ì œí•œë‹¤. * *row_count*: :ref:`limit-clause` ì—ì„œ ì‚ì œí• ë ˆì½”ë“œ 수를 ì§€ì •í•œë‹¤. 부호 없는 ì •ìˆ˜, 호스트 변수 ë˜ëŠ” 간단한 í‘œí˜„ì‹ ì¤‘ í•˜ë‚˜ì¼ ìˆ˜ 있다. ì‚ì œí• í…Œì´ë¸”ì´ í•œ ê°œì¸ ê²½ìš°ì— í•œí•˜ì—¬, :ref:`limit-clause`\ ì„ ì§€ì •í• ìˆ˜ 있다. :ref:`limit-clause`\ ì„ ëª…ì‹œí•˜ë©´ ì‚ì œí• ë ˆì½”ë“œ 수를 í•œì •í• ìˆ˜ 있다. :ref:`where-clause`\ ì„ ë§Œì¡±í•˜ëŠ” ë ˆì½”ë“œ 개수가 *row_count*\ 를 초과하면 *row_count* ê°œì˜ ë ˆì½”ë“œë§Œ ì‚ì œëœë‹¤. .. note:: \ * 여러 ê°œì˜ í…Œì´ë¸”ì´ ìžˆëŠ”(multiple table) **DELETE** 문ì—서는 <*table_specifications*> ë‚´ì—서만 í…Œì´ë¸” 별ì¹(alias)ì„ ì •ì˜í• 수 ìžˆê³ , <*table_specifications*> ë°–ì—서는 <*table_specifications*> ë‚´ì—ì„œ ì •ì˜í•œ í…Œì´ë¸” 별ì¹ë§Œ ì‚¬ìš©í• ìˆ˜ 있다. * CUBRID 9.0 미만 ë²„ì „ì—서는 <*table_specifications*>ì— í•œ ê°œì˜ í…Œì´ë¸”만 ìž…ë ¥í• ìˆ˜ 있다. .. code-block:: sql CREATE TABLE a_tbl( id INT NOT NULL, phone VARCHAR(10)); INSERT INTO a_tbl VALUES(1,'111-1111'), (2,'222-2222'), (3, '333-3333'), (4, NULL), (5, NULL); --delete one record only from a_tbl DELETE FROM a_tbl WHERE phone IS NULL LIMIT 1; SELECT * FROM a_tbl; :: id phone =================================== 1 '111-1111' 2 '222-2222' 3 '333-3333' 5 NULL .. code-block:: sql --delete all records from a_tbl DELETE FROM a_tbl; 아래 í…Œì´ë¸”ë“¤ì€ **DELETE JOIN**\ ì„ ì„¤ëª…í•˜ê¸° 위해 ìƒì„±í•œ 것ì´ë‹¤. .. code-block:: sql CREATE TABLE a_tbl( id INT NOT NULL, phone VARCHAR(10)); CREATE TABLE b_tbl( id INT NOT NULL, phone VARCHAR(10)); CREATE TABLE c_tbl( id INT NOT NULL, phone VARCHAR(10)); INSERT INTO a_tbl VALUES(1,'111-1111'), (2,'222-2222'), (3, '333-3333'), (4, NULL), (5, NULL); INSERT INTO b_tbl VALUES(1,'111-1111'), (2,'222-2222'), (3, '333-3333'), (4, NULL); INSERT INTO c_tbl VALUES(1,'111-1111'), (2,'222-2222'), (10, '333-3333'), (11, NULL), (12, NULL); ë‹¤ìŒ ì§ˆì˜ë“¤ì€ 여러 ê°œì˜ í…Œì´ë¸”ë“¤ì„ ì¡°ì¸í•œ 후 ì‚ì œë¥¼ 수행하며, ëª¨ë‘ ê°™ì€ ê²°ê³¼ë¥¼ 보여준다. .. code-block:: sql -- Below four queries show the same result. -- <DELETE multiple tables FROM ...> DELETE a, b FROM a_tbl a, b_tbl b, c_tbl c WHERE a.id=b.id AND b.id=c.id; DELETE a, b FROM a_tbl a INNER JOIN b_tbl b ON a.id=b.id INNER JOIN c_tbl c ON b.id=c.id; -- <DELETE FROM multiple tables USING ...> DELETE FROM a, b USING a_tbl a, b_tbl b, c_tbl c WHERE a.id=b.id AND b.id=c.id; DELETE FROM a, b USING a_tbl a INNER JOIN b_tbl b ON a.id=b.id INNER JOIN c_tbl c ON b.id=c.id; ì¡°ì¸ êµ¬ë¬¸ì— ëŒ€í•œ ìžì„¸í•œ ì„¤ëª…ì€ :ref:`join-query`\ 를 ì°¸ê³ í•œë‹¤.