database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 9913 게시물 읽기
No. 9913
postgresl에서 테이블 FK조회
작성자
postgres
작성일
2017-11-20 14:11ⓒ
2017-11-20 14:19ⓜ
조회수
7,144

특정 스키마의 특정 테이블에 대해서 FK가 존재하는지 확인하는 쿼리를 보고있는데

에러가 나네요;;

 

SELECT tc.table_name AS child_table,

kcu.column_name AS child_colum,

ccu.table_name AS foreign_table,

ccu.column_name AS foreign_column

FROM information_schema.table_constraints tc

JOIN information_schema.key_column_usage kcu ON tc.constraint_name::text = kcu.constraint_name::text

JOIN information_schema.constraint_column_usage ccu ON ccu.constarint_name::text = tc.constraint_name::text

WHERE tc.constraint_type = 'FOREIGN KEY' and tc.table_schema = 'testsch' and tc.table_name = 'testtable'

 

위 쿼리를 이용하여 testsch 스키마에 있는 testtable에 존재하는 FK를 보고싶은데

ERROR: column ccu.constarint_name does not exist

LINE 7: ...information_schema.constraint_column_usage ccu ON ccu.consta...

===>두번쨰 JOIN문의 ccu.constarint_name부분입니다.

^

HINT: Perhaps you meant to reference the column "ccu.constraint_name".

********** Error **********

 

ERROR: column ccu.constarint_name does not exist

SQL state: 42703

Hint: Perhaps you meant to reference the column "ccu.constraint_name".

Character: 349

 

이런 에러가 납니다.. 뭐가 문제인가요??

이 글에 대한 댓글이 총 2건 있습니다.

컬럼명을 오타내셨네요...

김주왕(kimjuking)님이 2017-11-20 14:16에 작성한 댓글입니다.

헐..죄송합니다..

postgres님이 2017-11-20 14:23에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
9916부모자식테이블간 참조하는 FK컬럼 조회 쿼리 [1]
postgres
2017-11-20
6928
9915소스에서 돌리던 계산을 function에서 하려는데요 [5]
최대호
2017-11-20
6611
9914HA 질문드립니다 [4]
검콤이
2017-11-20
6445
9913postgresl에서 테이블 FK조회 [2]
postgres
2017-11-20
7144
9912postgresql 에는 statistics 을 확인할수없나요? [1]
궁금
2017-11-20
6746
9911postgres초보 테이블 조회 관련 [6]
postgres
2017-11-15
7091
9910PostgreSQL 버전 관련 질문드립니다. [2]
이창기
2017-11-13
7022
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.050초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다