천재 블로그

[PostgreSQL] 제약 조건 확인 본문

프로그래밍/PostgreSQL

[PostgreSQL] 제약 조건 확인

Dondons 2019. 5. 13. 14:11

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- PostgrSQL 제약조건 확인
SELECT
    tb_con.table_catalog AS "데이터베이스 이름"
  , tb_con.table_name AS "테이블 이름"
  , tb_con.constraint_name AS "제약조건 이름"
  , ch_con.check_clause AS "체크 제약조건 내용"
FROM
  information_schema.table_constraints tb_con
    INNER JOIN information_schema.check_constraints ch_con
            ON tb_con.constraint_catalog = ch_con.constraint_catalog
           AND tb_con.constraint_schema = ch_con.constraint_schema
           AND tb_con.constraint_name = ch_con.constraint_name
WHERE
      tb_con.table_name = '테이블명'
  AND tb_con.constraint_type = 'CHECK'
ORDER BY
    tb_con.table_catalog
  , tb_con.table_name
  , tb_con.constraint_name
 



'프로그래밍 > PostgreSQL' 카테고리의 다른 글

[PostgreSQL] 컬럼 추가,제거, 변경 ALTER  (0) 2019.06.14
[postgreSQL]Character Set 확인  (0) 2019.05.30
[postgreSQL] PostgreSQL 접속  (0) 2019.05.28
Comments