PostgreSQL
-
postgresql 테이블 사이즈 확인하기프로그래밍/DB 2020. 7. 18. 22:25
postgresql 테이블 사이즈 확인하기 * 전체 테이블 사이즈 확인하기 select spcname, pg_size_pretty(pg_tablespace_size(spcname)) from pg_tablespace; * 테이블별 사이즈 확인하기 select pg_total_relation_size('테이블이름'); pg_size_pretty # select pg_total_relation_size('테이블이름'); pg_total_relation_size------------------------ 9829687296(1 row) MB, GB같은 단위로 보고싶으면 pg_size_pretty를 사용한다. # select pg_size_pretty(pg_total_relation_size('테이블이름'));..
-
psycopg2.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?프로그래밍/DB 2020. 3. 27. 19:51
postgresql 오류 처리 어느날 서버가 갑자기 다운되어서 재시작을 한 후 매번 잘 돌아가던 python 스크립트에서 갑자기 오류를 내기 시작했다. 참고로 스크립트에서 변경된 사항은 전혀 없었다. Traceback (most recent call last): File "getInfoPost.py", line 379, in conn = pc.connect("dbname=realdbname user=username password=realpass") File "/root/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect conn = _connect(dsn, connection_factory=connection..
-
postgreSQL 사용법 - 테이블 업데이트프로그래밍/DB 2019. 9. 28. 16:09
postgresql 테이블 업데이트 방법 ( how to update postgresql table ) 다른 테이블 필드 값으로 업데이트 update table2 as f set field1 = h.field1 from table1 as h where f.field2 = 2 and f.id = h.id; 같은 테이블 필드를 분리해서 업데이트 update 테이블이름 set 본번 = split_part(지번, '-',1); 특정 값으로 전체 필드 업데이트 update 테이블이름 set 칼럼이름='문자열'