DBEAVER 라는 프로그램을 설치했다.
이렇게 생긴 프로그램인데 VISUAL STUDIO CODE랑 비슷하게 생겼다.
입문
1) SELECT와 WHERE
쿼리문은 데이터베이스에 명령을 내리는 것을 말한다.
2) Where절과 같이 쓰는 문법
(1) select 쿼리문에 where 절 함께 써보기
select * from orders
where payment_method = "kakaopay"
orders 테이블에서 payment_method가 kakaopay 인것만 가져와달라는 의미가 됨.
(2) where 절과 같이 쓰는 문법
같지않음 : !=
select * from orders
where course_title != "웹개발 종합반"
orders 테이블에서 course_title이 웹개발 종합반이 아닌 데이터만 가져와줘
범위 조건 : between a and b
select * from orders
where created_at between "2020-07-13" and "2020-07-15";
orders 테이블에서 created_at 날짜가 13일에서 14일 사이인 데이터만 가져와줘
포함 : in (a,b)
select * from checkins
where week in (1, 3);
checkins 데이터에서 1주차, 3주차 데이터만 가져와줘
패턴 : like 와 %
select * from users
where email like '%daum.net';
daum 이메일을 사용하는 유저의 데이터만 가져와줘
(3) 이외의 문법
limit
select * from orders
where payment_method = "kakaopay"
limit 5;
orders 테이블에서 kakaopay를 사용하는 유저의 데이터를 5개만 가져와줘
distinct
select distinct(payment_method) from orders;
orders 테이블에서 payment_method만 중복없이 가져와줘
count
select count(*) from orders
orders의 총 데이터 수를 한줄한줄씩 세어줘
distinct & count
SELECT count(distinct(name)) from users;
users 테이블에서 name을 중복없이 나열하고 갯수를 세어줘
이렇게 1주차 수업이 마무리되었다.
컴퓨터활용능력 필기 3과목 공부할때 select문과 where절 조건에 대해서 얄팍하게나마 공부를 했었는데 직접 DBeaver 프로그램도 설치하고 쿼리를 짜서 데이터를 나열해보니 재밌다.
오늘 처음으로 코드도 입력해봤는데 코드를 이렇게 입력해보는 건 처음이라 그런지 글 적는게 조금 미숙하다. 다음 내용이 전에 입력한 코드 칸에 엮어져서 들어가고 난리다..
첫 개발일지 끝!