inblog logo
|
jay0628
    Database

    [DB] 6. 데이터 조작 (DML)

    김주희's avatar
    김주희
    Feb 26, 2025
    [DB] 6. 데이터 조작 (DML)
    Contents
    0. DML 전 유의사항1. INSERT2. UPDATE3. DELETE

    0. DML 전 유의사항

    ❗
    safe update 설정 해제 필수!
    notion image
     
    notion image
     

    1. INSERT

    ❗
    스키마 체크
    select * from bonus; desc bonus;
    notion image
    notion image
    insert into bonus(ename, job, sal, comm) values('홍길동', '프로그래머', 600, 100); insert into bonus(ename, job, sal, comm) values('임꺽정', '변호사', 1000, 200);
    1. affected 체크
      1. notion image
    1. select * from bonus로 확인해보기
      1. notion image
     

    2. UPDATE

    -- 2. UPDATE update bonus set sal = 2000, comm = 500 where job = '프로그래머';
    1. ‘1 row(s) affected Rows matched: 1 Changed: 1 Warnings: 0’ 체크
      1. notion image
    1. select * from bonus로 확인해보기
      1. notion image
     
    -- job이 변호사인 친구의 이름을 임하룡으로 변경하시오. update bonus set ename = '임하룡' where job = '변호사';
    1. ‘1 row(s) affected Rows matched: 1 Changed: 1 Warnings: 0’ 체크
      1. notion image
    1. select * from bonus로 확인해보기
      1. notion image
     

    3. DELETE

    delete from bonus where job = '프로그래머';
    1. affected 체크
      1. notion image
    1. select * from bonus로 확인해보기
      1. notion image
     

    전체 코드

    -- DML (데이터 조작어) -- 1. INSERT select * from bonus; desc bonus; insert into bonus(ename, job, sal, comm) values('홍길동', '프로그래머', 600, 100); insert into bonus(ename, job, sal, comm) values('임꺽정', '변호사', 1000, 200); -- 2. UPDATE update bonus set sal = 2000, comm = 500 where job = '프로그래머'; -- job이 변호사인 친구의 이름을 임하룡으로 변경하시오. update bonus set ename = '임하룡' where job = '변호사'; -- 3. DELETE delete from bonus where job = '프로그래머';
    Share article

    jay0628

    RSS·Powered by Inblog