inblog logo
|
Coding_study
    SQL)MariaDB

    [MariaDB] 샘플 데이터 이용하기

    yuzu sim's avatar
    yuzu sim
    Nov 29, 2023
    [MariaDB] 샘플 데이터 이용하기
    Contents
    Maria DB 샘플 데이터 다운로드환경변수 설정CMD로 DB 이용집계함수

    Maria DB 샘플 데이터 다운로드

    notion image
    구글에 '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
    notion image
    test_db 페이지 접속
    notion image
    코드에 'Download zip' 다운로드
    notion image
    압축풀기
    명령 프롬프트(Command Prompt, cmd.exe)
    Window의 기본 유틸리티, Windows NT 계열 OS의 커맨드라인 해석기(CLI)
    • 커맨드라인 해석기(CLI: Command Line Interface): 글자를 입력하여 컴퓨터에 명령을 내리는 방식
    • 그래픽 사용자 인터페이스(GUI: Graphical User Interface)
    사용자가 편리하게 사용할 수 있도록 입출력 등의 기능을 알기 쉬운 아이콘 따위의 그래픽으로 나타낸 것
    notion image
    환경변수 설정 전
    mysql이라는 폴더가 들어있지 않기에 CMD로 호출할 수 없음
    환경변수 설정이 필요함
    • 환경변수: 프로세스가 컴퓨터에서 동작하는 방식에 영향을 미치는, 동적인 값들의 모임
    환경변수가 필요한 이유
    프로세스가 어떠한 작업을 할 때 필요로 하는 정보를 손 쉽게 접근.처리할 수 있도록 해주는 것

    환경변수 설정

    notion image
    시스템 정보에 고급 시스템 설정
    notion image
    고급 탭
    notion image
    환경변수
    notion image
    시스템 변수에 Path 더블클릭
    notion image
    새로 만들기
    notion image
    MariaDB 10.11\bin 입력
    notion image
    확인
    notion image
    확인후 창 닫기

    CMD로 DB 이용

    • CD(Change Directory) or CD.. : 폴더 이동
    • DIR(DIRectory): 전체파일을시간순으로 정렬
    notion image
    MariaDB 10.11 위치 확인
    notion image
    MariaDB 10.11폴더 안의 bin 폴더로 이동
    notion image
    bin 폴더에서 root 계정으로 접속
    notion image
    DB 사용
    notion image
    DB안에 있는 테이블 출력
    notion image
    내림차순으로 테이블 정렬
    notion image
    DB 생성
    notion image
    DB 생성 확인
    notion image
    employees 파일 열기
    notion image
    모든 레코드의 수 세기

    집계함수

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

    Coding_study

    RSS·Powered by Inblog