Dorito
Schema와 Table 차이 (mySQL , PostgreSQL)
Dorito
Dorito's Dev
Dorito
전체
오늘
어제
  • 분류 전체보기 (28)
    • 재밌는 개발글이지만 아직 미분류 (1)
    • Infra (2)
      • ELK stack (2)
    • 인프라 (0)
    • 백엔드 (3)
      • 🐈️ Nest.js (3)
    • 프론트엔드 (0)
      • 🐏️ Next.js (0)
    • 알고리즘 (12)
      • 프로그래머스 (8)
      • 리트코드 (1)
      • SQL (1)
      • SQL-1 (2)
    • 궁금증 해결 (8)
      • 개념 (7)
      • 에러 (0)
      • 구현 (0)
    • 비공개 (0)
    • 잡동사니 (1)

블로그 메뉴

  • 글쓰기
  • 홈
  • 태그
  • 방명록
  • 관리

공지사항

인기 글

태그

  • web
  • JavaScript
  • redis
  • Elasticsearch
  • error-log
  • Next.js
  • Infra
  • CachManager
  • ELK Stack
  • 에러 해결
  • nestjs
  • study
  • react
  • typescript

최근 댓글

최근 글

hELLO · Designed By 정상우.
궁금증 해결/개념

Schema와 Table 차이 (mySQL , PostgreSQL)

2022. 12. 20. 17:10
목차
  1. PostgreSQL | 스키마(Schema) | 데이터베이스, 스키마, 테이블의 관계
  2. 스키마
  3. 테이블

# 참고 문서)
MySQL :: MySQL 8.0 Reference Manual :: 13.1.12 CREATE DATABASE Statement
Difference Between Schema / Database in MySQL - Stack Overflow

  • mySQL
    schema is a collection of tables and a Database is a collection of schemas.
    CREATE DATABASE creates a database with the given name. To use this statement, you need the CREATE privilege for the database. CREATE SCHEMA is a synonym for CREATE DATABASE as of MySQL 5.0.2.

 

  • postgreSQL

PostgreSQL: Documentation: 15: 5.9. Schemas PostgreSQL supports schemas, which is a subset of a database:

A database contains one or more named schemas, which in turn contain tables. Schemas also contain other kinds of named objects, including data types, functions, and operators. The same object name can be used in different schemas without conflict; for example, both schema1 and myschema can contain tables named mytable. Unlike databases, schemas are not rigidly separated: a user can access objects in any of the schemas in the database they are connected to, if they have privileges to do so.

in MySQL schema is synonym of database. Its quite confusing for beginner people who jump to MySQL and very first day find the word schema, so guys nothing to worry as both are same.

When you are starting MySQL for the first time you need to create a database (like any other database system) to work with so you can CREATE SCHEMA which is nothing but CREATE DATABASE

In some other database system schema represents a part of database or a collection of Tables, and collection of schema is a database.

 

 

PostgreSQL | 스키마(Schema) | 데이터베이스, 스키마, 테이블의 관계

# 참고 문서) PostgreSQL | 스키마(Schema) | 데이터베이스, 스키마, 테이블의 관계 | devkuma

 

스키마

 

PostgreSQL에서 실제 데이터는 테이블에 저장된다. 테이블은 목적에 따라 여러 개 만들 수 있고 그것을 정리된 것이 데이터베이스이며, 거기에 PostgreSQL에서는 데이터베이스에 스키마라는 것이 있다.

스키마는 데이터베이스에 작성되는 테이블이나 함수 등의 개체를 그룹화하는 것이다. (postgres에서의 스키마는 테이블의 집합을 의미)

스키마가 다르면 동일한 데이터베이스에도 동일한 테이블 이름으로 테이블을 만들 수 있다. 데이터베이스를 작성하면 자동으로 public라는 특별한 스키마가 작성된다.

 

public 스키마는 기본적으로 모든 역할에 권한과 CREATE 권한이 부여되며, public 스키마에 어떤 역할도 테이블을 만들 수 있다.

public 스키마와는 별도로 스키마를 데이터베이스에 만들 수 있다. 다른 데이터베이스 시스템에서는 사용자 이름과 동일한 이름의 스키마 이름을 가진 스키마만 작성할 수 없는 것도 있지만, PostgreSQL에서는 모든 이름의 스키마를 만들 수 있다.

테이블

테이블은 스키마에 작성한다. 스키마가 다르면 같은 테이블 이름의 테이블도 만들 수 있다.

또한 스키마마다 테이블 등의 오브젝트를 작성할 수있는 권한을 설정할 수 있다.

CREATE TABLE 명령으로 테이블을 만들 경우 테이블 이름에 스키마를 생략하면 기본적으로 public 스키마에 테이블이 만들어 진다. (역할 이름과 같은 스키마가 생성 된 경우는 제외)

 

 

 

database >= schema > table 이렇게 이해함

저작자표시 (새창열림)

'궁금증 해결 > 개념' 카테고리의 다른 글

QnA [Jest] What is the difference between describe and it in Jest?  (0) 2022.12.19
QnA [Java] 스택 자료구조 쓸 때 뭘 써야하는가  (0) 2022.12.19
QnA [Java] Interface Naming convention  (0) 2022.12.19
spyOn()과 jest.fn()의 차이  (1) 2022.12.05
타입스크립트 Interface, Type의 차이와 관련 연산자 (타입 합칠 때 & 사용)  (0) 2022.12.03
  • PostgreSQL | 스키마(Schema) | 데이터베이스, 스키마, 테이블의 관계
  • 스키마
  • 테이블
'궁금증 해결/개념' 카테고리의 다른 글
  • QnA [Jest] What is the difference between describe and it in Jest?
  • QnA [Java] 스택 자료구조 쓸 때 뭘 써야하는가
  • QnA [Java] Interface Naming convention
  • spyOn()과 jest.fn()의 차이
Dorito
Dorito
"Premature optimization is the root of all evil" - Donald Knuth
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.