
[Postgresql] 테이블내의 컬럼 정보 조회 ( 데이터 타입, 널 가능여부, 길이, 컬럼명 .... )
데이터베이스/Postgresql
2022. 3. 30. 21:38
가끔 필요할 때가 있는데, 그때마다 찾기가 귀찮아서 이렇게 정리한다. 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 = [스키마명] and table_name = [테이블명] ORDER BY 테이블이름, ORDINAL_POSITION; 여기서 딱 ..