본문 바로가기
728x90

프로그래밍/Database9

Postgresql procedure DO $$ DECLARE c1 varchar(10) := 'aaa'; rslt record; BEGIN FOR rslt IN ( SELECT * FROM ord WHERE 1 = 1 AND ord_stat_cd = 'ALL_CNCL' ) LOOP RAISE info 'ord_no : %, mbr_no : %', rslt.ord_no, rslt.mbr_no; END LOOP; raise info 'inner procedure) mina :%', c1; END; $$ https://blog.naver.com/noranja69/222377019312 Procedure에서의 Exception처리 비교(PostgreSql vs Oracle) 생각나는대로 ... blog.naver.com 2022. 2. 10.
PostgreSQL 에러 에러) SQL Error [42P04]: 오류: "test1" 이름의 데이터베이스는 이미 있음 DBeaver에서 "test1" 데이터베이스 생성시 에러남.기존에 생성된 "test1" 데이터베이스가 있지만 postgresql 접속시 보이지 않아서 다시 생성하려 했을때 위와 같은 에러가 났음. 해결) 커넥션 설정을 수정함. edit connection -> PostgreSQL tab의 Show all databases option 체크하고 다시 접속하면 모든 데이터베이스가 보임. 2021. 12. 22.
PostgreSQL 외부 데이터베이스 테이블을 참조하기 위한 fdw 설정 1. fdw를 테스트하기 위해 데이터베이스 2개(test, test1)를 생성함 test 데이터베이스에서 test1 데이터베이스의 테이블을 참조하기 위해 아래와 같이 실행함. 1. fdw 생성 CREATE EXTENSION postgres_fdw; 2. 외부 서버 생성 CREATE SERVER test1_svr FOREIGN DATA WRAPPER postgres_fdw -- 1번에서 생성한 postgres_fdw OPTIONS ( -- test1 데이터베이스 정보 host 'localhost', port '5432', dbname 'test1' ); 3. 사용자 매핑 생성 test 접속 사용자와 test1 접속 사용자를 매핑해줌 CREATE USER MAPPING FOR postgres -- test .. 2021. 12. 22.
PostgreSQL 쿼리 -- 테이블 명세 조회SELECT c.relname AS table_name, pg_catalog.obj_description(c.oid, 'pg_class') AS table_comment, a.attname AS column_name, col_description(a.attrelid, a.attnum) AS column_comment, CASE WHEN pg_catalog.format_type(a.atttypid, a.atttypmod) LIKE 'timestamp%' THEN 'timestamp'-- WHEN pg_catalog.format_type(a.atttypid, a.atttypmod) LIKE 'character varying%' THEN '' .. 2021. 12. 10.
728x90