PostgreSQL
-
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 칼럼이름='문자열'
-
[ postgreSQL] 다른 테이블 복사하기프로그래밍/DB 2019. 9. 28. 15:44
PostgreSQL 사용법 다른 테이블 구조 & 데이터 복사하기 다른 테이블 구조와 데이터 복사하기 CREATE TABLE newtable AS SELECT * FROM oldtable; 다른 테이블 구조만 복사하기 CREATE TABLE newtable ( LIKE oldtable ); 데이터 & 인덱스 & constraint 등의 정보 다 같이 복사하기 아래 두개의 sql 문을 차례로 실행한다. 복사 속도는 위의 방식이 더 빠르지만 인덱스 정보가 같이 복사됨. create table newtable (like "oldtable" including all);insert into newtable ( select * from "oldtable"); 다른 테이블의 일부 필드만 복사하기 insert into ..