[SQL][MySQL] DML ( Data Manipulation Language ) - INSERT, UPDATE, DELETE

728x90

 

  Row

▼  추가

INSERT [INTO] table_name [(col_name1 [, col_name2] ...)] {VALUES | VALUE} (value1 [, value2] ...);
/* INSERT INTO Reservation(ID, Name) VALUES (5, '김라라'); */

-  필드(컬럼) 이름 생략 시, 스키마와 같은 순서대로 필드 값이 자동 대입됨

< 생략 가능한 필드 >
  1.  NULL 값이 허용된 필드
  2.  DEFAULT 제약 조건이 설정된 필드
  3.  AUTO_INCREMENT 키워드가 설정된 필드

▼  수정

UPDATE table_name SET column_name = new_value [, column_name = new_value ...] [WHERE ...] [ORDER BY ...];

▼  삭제

DELETE FROM table_name [WHERE where_condition] [ORDER BY ...];

-  WHERE 절 생략 시 테이블에 저장된 모든 데이터가 삭제됨 ( 테이블은 그대로 )
-  행 삭제 후 삭제 된 행의 수 반환

 

https://dev.mysql.com/doc/refman/8.0/en/insert.html

더보기
더보기
더보기
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    { {VALUES | VALUE} (value_list) [, (value_list)] ...
      |
      VALUES row_constructor_list
    }
    [AS row_alias[(col_alias [, col_alias] ...)]]
    [ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [AS row_alias[(col_alias [, col_alias] ...)]]
    SET assignment_list
    [ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    [AS row_alias[(col_alias [, col_alias] ...)]]
    {SELECT ... | TABLE table_name}
    [ON DUPLICATE KEY UPDATE assignment_list]

value:
    {expr | DEFAULT}

value_list:
    value [, value] ...

row_constructor_list:
    ROW(value_list)[, ROW(value_list)][, ...]

assignment:
    col_name = [row_alias.]value

assignment_list:
    assignment [, assignment] ...

https://dev.mysql.com/doc/refman/8.0/en/update.html

더보기
더보기
더보기
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
    SET assignment_list
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

value:
    {expr | DEFAULT}

assignment:
    col_name = value

assignment_list:
    assignment [, assignment] ...

https://dev.mysql.com/doc/refman/8.0/en/delete.html

더보기
더보기
더보기
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
    [PARTITION (partition_name [, partition_name] ...)]
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

 

 

반응형