06-SQL-Docker
1. SQL 기본기
sql
1-- select {column} from {table}2select id, author, title, content3from post;45-- update {table} set {column} where {condition}6update post set likeCount = 07where id =3;89-- delete from {table} where {condition}10delete from post11where author = 'newjeans_official';1213-- insert into {table} {column1, column2, ...}14-- values {value1, value2, ...}15insert into posts (id, author, title)16values (7, '나다', '제목');
2. Docker 이론
개발자들이 가진 컴퓨터, OS가 다 다르기 때문에, 환경에 따라 코드가 실행이 될 수도 안 될 수도 있었다.
Windows, macOS, Linux 등의 환경들을 서로 호환되게 하기 위해서 과거부터 많은 시도들이 있었다. 또 설치 가이드 역시 표준화하여 OS가 달라도 같은 결과를 실행할 수 있게 한다.
4. Docker 설치
5. Docker-Compose
docker-compose.yaml
1# 서비스정의2services:3postgres:4image: postgres:155# 실행시마다 재시작6restart: always7# 도커컴포즈 파일에 존재하는 위치에 실제 데이터를 hostOS에 저장8volumes:9# 현재 도커컴포즈 파일이 존재하는 경로 : 이미지안에존재하는 경로 매핑10- ./postgres-data:/var/lib/postgresql/data11ports:12# hostport:이미지의포트13# 5432포트 요청 -> 이미지의 포트로 요쳥14- '5808:5432'15environment:16POSTGRES_USER: postgres17POSTGRES_PASSWORD: postgres18POSTGRES_DB: postgres
postgres-data 폴더를 만든 다음, 아래 명령어로 docker를 켭니다.
shellscript
1docker-compose up
6. VSC에서 Postersql 확장도구
vscode에서 실행창(cmd + p)로 postgresql:add Connection 검색
- 127.0.0.1
- postgres (환경설정에 입력한 유저명)
- postgres (환경설정에 입력한 비밀번호)
- 5432
- standard connection
- 포트번호를 잘 설정해서 그냥 enter
- nestjs_local_database (연결 이름명 설정)
앞으로 실습하려면
- docker 프로그램 켜고,
- docker-compose 이미지를 실행(
docker-compose up)- nestjs 프로그램 실행