
Maria DB 샘플 데이터 다운로드

구글에 'mariadb 샘플 데이터' 검색
다운로드 사이트: https://github.com/datacharmer/test_db
GitHub - datacharmer/test_db: A sample MySQL database with an integrated test suite, used to test your applications and database servers
A sample MySQL database with an integrated test suite, used to test your applications and database servers - GitHub - datacharmer/test_db: A sample MySQL database with an integrated test suite, use...
github.com

test_db 페이지 접속

코드에 'Download zip' 다운로드

압축풀기
명령 프롬프트(Command Prompt, cmd.exe)
Window의 기본 유틸리티, Windows NT 계열 OS의 커맨드라인 해석기(CLI)
- 커맨드라인 해석기(CLI: Command Line Interface): 글자를 입력하여 컴퓨터에 명령을 내리는 방식
- 그래픽 사용자 인터페이스(GUI: Graphical User Interface)
사용자가 편리하게 사용할 수 있도록 입출력 등의 기능을 알기 쉬운 아이콘 따위의 그래픽으로 나타낸 것

환경변수 설정 전
mysql이라는 폴더가 들어있지 않기에 CMD로 호출할 수 없음
환경변수 설정이 필요함
- 환경변수: 프로세스가 컴퓨터에서 동작하는 방식에 영향을 미치는, 동적인 값들의 모임
환경변수가 필요한 이유
프로세스가 어떠한 작업을 할 때 필요로 하는 정보를 손 쉽게 접근.처리할 수 있도록 해주는 것
환경변수 설정

시스템 정보에 고급 시스템 설정

고급 탭

환경변수

시스템 변수에 Path 더블클릭

새로 만들기

MariaDB 10.11\bin 입력

확인

확인후 창 닫기
CMD로 DB 이용
- CD(Change Directory) or CD.. : 폴더 이동
- DIR(DIRectory): 전체파일을시간순으로 정렬

MariaDB 10.11 위치 확인

MariaDB 10.11폴더 안의 bin 폴더로 이동

bin 폴더에서 root 계정으로 접속

DB 사용

DB안에 있는 테이블 출력

내림차순으로 테이블 정렬

DB 생성

DB 생성 확인

employees 파일 열기

모든 레코드의 수 세기
집계함수
여러행으로부터 하나의 결과값을 반환하는 함수
기본 함수들은 행끼리 연산
집계함수는 열끼리 연산
주로 평균값, 합, 최대, 최소 등을 구하는데 사용됨
- COUNT: 특정 열의 행의 개수를 세누느 함수
- MIN/MAX: 최소값/최대값을 구하는 함수
- AVG: 선택한 열의 평균값을 구하는 함수
- SUM: 선택한 열의 합을 구하는 함수
- GROUP BY: 테이블 일부의 행을 대상으로 집계함수를 사용
- HAVING: WHERE 와 같이 쓰이는 조건절
WHERE에서는 집계 함수를 사용할 수 없음???
문제) 성별로 그룹을 지어서 남자가 몇명이고 여자가 몇명인지 결과 내보기
젠더로 그룹을 지으면 셀렉트에도 그룹을 써준다
having은 그룹을 지은 상황에서 조건을 하고 싶을때

그룹별 총점 조회

조건에 맞는 그룹별 총점 조회

조건에 맞는 그룹 총점 조회

그룹별 합계 조회

조건에 맞는 그룹별 합계 조회
Share article