jinseon's log

[엘카데미] 엘카데미 챌린지_SQL 레벨 테스트_19일차 본문

ML & DL/엘카데미

[엘카데미] 엘카데미 챌린지_SQL 레벨 테스트_19일차

J_SEON 2023. 8. 4. 13:47

 

[첫 번째 이야기]

[문제 1] DB 확인하기

select
    *
from
    student;

 

[문제 2] 학년 수정하기

- `update set` 짝궁처럼 기억하기

- 명령어가 잘 생각이 나지 않는다

update
    student
set
    grade = grade + 1;

select 
    *
from
    student;

 

[문제 3] 새로운 학생 추가하기

- `insert into ~ values` 도 자꾸 잊어버린다

insert into
    student
values
    (1005, "Alice", 1, 104),
    (1006, "Bob", 1, 104),
    (1007, "Charles", 1, 105);

select
    *
from
    student
where
    id between 1005 and 1007;

 

[문제 4] 별점 항목 추가

- `alter table ~ add` 다른 명령어들과 비슷한 듯 달라서 헷갈린다

alter table
    student
add
    caution int;

update
    student
set
    caution = 0;

select
    caution
from
    student;

 

[문제 5] 경고 부여하기

update
    student
set 
    caution = caution + 1
where
    grade = 3;

select
    *
from
    student
where
    caution >= 1;

 

명령어 헷갈리지 않고 기억하기 !

- `insert into ~ values`

- `update ~ set`

- `alter table ~ add`

Comments