copy from만 써서 몰랐는데

to를 써서 파일로 지정해주면 csv 포맷으로 출력이 가능하다고 한다.

 

[링크 : https://www.postgresqltutorial.com/export-postgresql-table-to-csv-file/]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgresql 제약조건 관련  (0) 2020.02.07
postgresql database / table 복제 및 동기화  (0) 2020.02.07
Pk (Primary Key)  (0) 2020.02.07
N:M 관계 해소  (0) 2020.02.07
sql에서 null 비교  (0) 2020.02.07
Posted by 구차니

primary 키는 테이블에서 유일해야 한다.

반대로 생각하면 데이터들을 가지고 테이블을 만들때 pk로 만들려고 하면

해당 필드의 값들이 유일한 값으로 구성되어 있는지 증명이 되어야 한다.

[링크 : https://blog.naver.com/qbxlvnf11/221198309383]

[링크 : https://blog.naver.com/dalami0i/221048091824]

 

 

replica 계정으로 오면 constraint가 전부 무효화 되는 듯하다.

[링크 : https://stackoverflow.com/questions/2679854/postgresql-disabling-constraints]

 

오라클에서는 삭제,추가 외에 enable, disable이 존재한다고 한다.

[링크 : https://ttend.tistory.com/632]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

psql copy to  (0) 2020.02.10
postgresql database / table 복제 및 동기화  (0) 2020.02.07
Pk (Primary Key)  (0) 2020.02.07
N:M 관계 해소  (0) 2020.02.07
sql에서 null 비교  (0) 2020.02.07
Posted by 구차니

하나의 백업 db를 두고 싶어서 어떻게 동기화 해야 하나 찾아보는중

WAL 로그가 있으니 그걸 기반으로 주고받으려나?

 

[링크 : https://dba.stackexchange.com/questions/170709/need-to-sync-postgresql-db-to-remote]

[링크 : https://stackoverflow.com/questions/6385546/synchronization-between-two-servers-postgres-database]

[링크 : http://wiki.postgresql.org/wiki/Streaming_Replication]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

psql copy to  (0) 2020.02.10
postgresql 제약조건 관련  (0) 2020.02.07
Pk (Primary Key)  (0) 2020.02.07
N:M 관계 해소  (0) 2020.02.07
sql에서 null 비교  (0) 2020.02.07
Posted by 구차니

unique, not null

으로 정의되는 녀석이다.

테이블 내에서 중복되서 나타나서는 안되는 '유일성'을 보장하기 위한 수단.

 

[링크 : http://kdskor.blogspot.com/2010/10/pk-fk.html]

[링크 : https://alljbut.tistory.com/40]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgresql 제약조건 관련  (0) 2020.02.07
postgresql database / table 복제 및 동기화  (0) 2020.02.07
N:M 관계 해소  (0) 2020.02.07
sql에서 null 비교  (0) 2020.02.07
ER 다이어그램 식별 / 비식별  (0) 2020.02.07
Posted by 구차니

N:M 관계를 가지게 되면 1:N 관계로 환원 후 

새로운 맵핑테이블을 만들고 Pk로 Auto increment 주고 나서

양쪽의 fk를 비식별 관계로 일반 entity로 사용하면 해결된다.. 인가?

 

[링크 : https://blog.naver.com/karerina82/132507978]

[링크 : https://siyoon210.tistory.com/26]

Posted by 구차니

 

[링크 : https://neovader.tistory.com/111]

 

이 조항으로 인해서 해당 값이 NULL 이고 비교할 값이 NULL 이면

TRUE로 될지 FALSE로 될지 모른다 인가?

NULL과 NULL은 "같은" 관계가 없기 때문에, expression = NULL라고 기술하면 안됩니다 (NULL 값은 불명의 값을 나타내며 알 수 없는 값이기 때문에 서로 같은지 여부는 확인할 수 없습니다) . 이것은 표준 SQL에 따른 동작입니다.

[링크 : https://blog.naver.com/kngt13/80133873398]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

Pk (Primary Key)  (0) 2020.02.07
N:M 관계 해소  (0) 2020.02.07
ER 다이어그램 식별 / 비식별  (0) 2020.02.07
pg_dump -n 으로 특정 스키마만 백업하기  (0) 2020.02.04
drop database와 postgres  (0) 2020.02.04
Posted by 구차니

erdcloud에서 다른 사람들이 그린걸 보는데 의외로

식별은 별로 없고 비식별이 대부분이라 두개가 어떤 차이인지 찾아보는 중..

 

외래키는 Fk 일텐데 기본키는 멀까..

일단 Fk를 일반 속성으로 쓰면 비식별 관계가 되는 듯.

외래키들을 기본키로 사용하지않고 일반 속성으로 취급하는 관계를 비식별관계라고 표현한다. 눈매가 예리한 사람들은 느꼈겠지만 ERD에서 비식별 관계는 관계를 점선으로 표시한다.

기본키 포스팅에서도 말했지만 추후 비즈니스 모델 변경에도 영향을 최소화하기위해 이런 관계 테이블에도 식별 관계보다는 인조키를 이용한 비식별 관계를 권장한다.

[링크 : https://multifrontgarden.tistory.com/181]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

N:M 관계 해소  (0) 2020.02.07
sql에서 null 비교  (0) 2020.02.07
pg_dump -n 으로 특정 스키마만 백업하기  (0) 2020.02.04
drop database와 postgres  (0) 2020.02.04
union / intersect / minus  (0) 2020.01.22
Posted by 구차니

 

-n schema
--schema=schema
Dump only schemas matching schema; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql's \d commands (see Patterns), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples.

Note: When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.

Note: Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch.

-N schema
--exclude-schema=schema
Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n. -N can be given more than once to exclude schemas matching any of several patterns.

When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n, then schemas matching -N are excluded from what is otherwise a normal dump.

[링크 : https://www.postgresql.org/docs/9.1/app-pgdump.html]

[링크 : https://stackoverflow.com/questions/14486241/how-can-i-export-the-schema-of-a-database-in-postgresql]

[링크 : https://dba.stackexchange.com/questions/53185/postgresql-how-to-backup-only-one-schema-from-a-database-and-restore-it-on-anot]

 

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

sql에서 null 비교  (0) 2020.02.07
ER 다이어그램 식별 / 비식별  (0) 2020.02.07
drop database와 postgres  (0) 2020.02.04
union / intersect / minus  (0) 2020.01.22
one to one , one to only one  (0) 2020.01.17
Posted by 구차니

postgresql은 WAL로 인해서 table을 drop 해도 용량이 늘어나고

full vacuum을 통해서 공간을 줄일수 있다.

 

유일한 예외(?)가 drop database

하드 디스크 거의 100% 채워서 뻗은 시스템을 이제야 복구하는데

 

drop database [database_name]

해주면서 df -h 를 보고 있노라니 용량이 쑥쑥 줄어든다.

 

아무튼 공간 부족해서 터져 나간건 복구도 힘들구나.. 라는걸 깨닫는 중

Posted by 구차니

허... union / union all만 알았는데

집합 레벨에서 교집합을 join 없이 구할 수 있다니

난 무슨 바보짓을 해온건가 ㅠㅠ

 

[링크 : https://keep-cool.tistory.com/45]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

pg_dump -n 으로 특정 스키마만 백업하기  (0) 2020.02.04
drop database와 postgres  (0) 2020.02.04
one to one , one to only one  (0) 2020.01.17
EA(Enterprise Architecture)  (0) 2020.01.17
데이터베이스 모델링  (0) 2020.01.17
Posted by 구차니