728x90
SMALL
DB에있는 모든 컬럼 조회 및 테이블별 정렬
SELECT TABLE_NAME as 테이블이름, column_name as 컬럼명,
is_nullable as null가능여부,
data_type as 데이터타입,
character_maximum_length as 최대길이,
character_octet_length,
numeric_precision,
numeric_precision_radix,
numeric_scale
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_CATALOG = 'DB이름'
and table_schema = '스키마이름'
ORDER BY 테이블이름, ORDINAL_POSITION;
예) public스키마의 test데이터베이스내의 tableA의 모든 컬럼명만 조회
SELECT column_name as 컬럼명
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_CATALOG = 'test'
and table_schema = 'public'
and table_name = 'tableA';
728x90
LIST
'DB > Postgresql' 카테고리의 다른 글
[postgresql] table join하여 여러개 행 update, select하여 여러칼럼 update (0) | 2022.06.24 |
---|---|
postgresql 소수점 뒤로 두자리 나오도록, 소수점 0 표시, to_char 0표시 (0) | 2022.05.27 |
[postgresql] null 체크하는 방법, null 데이터 문자열로 치환 - COALESCE 함수 (0) | 2022.05.24 |
POSTGRESQL 테이블명세서 테이블정의서 추출 쿼리 (0) | 2021.12.21 |
해당문자열 다른문자열로 치환 update문 (0) | 2021.12.16 |
댓글