반응형
모든 테이블 이름을 나열하는 PostgreSQL 쿼리?
Postgres DB의 모든 테이블을 나열하는 데 사용할 수있는 쿼리가 있습니까?
나는 다음과 같은 하나의 쿼리를 시도했다.
SELECT table_name FROM information_schema.tables
WHERE table_schema='public'
그러나이 쿼리는 뷰도 반환합니다.
뷰가 아닌 테이블 이름 만 얻을 수 있습니까?
이 검색어에 대한 설명은 무엇입니까 ( manual 의 설명에 따라 )?
SELECT table_name
FROM information_schema.tables
WHERE table_schema='public'
AND table_type='BASE TABLE';
데이터베이스 목록을 원한다면
SELECT datname FROM pg_database WHERE datistemplate = false;
모든 데이터베이스의 현재 pg 설치에서 테이블 목록을 원하는 경우
SELECT table_schema,table_name FROM information_schema.tables
ORDER BY table_schema,table_name;
원하는 데이터베이스를 사용하여 postgres 터미널을 엽니 다.
psql dbname (run this line in a terminal)
그런 다음 postgres 환경에서이 명령을 실행하십시오.
\d
이름별로 모든 테이블을 설명합니다. 기본적으로 이름 오름차순으로 된 테이블 목록입니다.
그런 다음 필드별로 테이블을 설명하기 위해 시도해 볼 수 있습니다.
\d tablename.
도움이 되었기를 바랍니다.
select
relname as table
from
pg_stat_user_tables
where schemaname = 'public'
- track_activities 가 비활성화 된 경우 작동 하지 않습니다
select
tablename as table
from
pg_tables
where schemaname = 'public'
- pg_tables 에 대해서 더 읽어보세요.
어떻게 그냥주는 약 \dt
에 psql
? https://www.postgresql.org/docs/current/static/app-psql.html을 참조 하십시오 .
이 시도:
SELECT table_name
FROM information_schema.tables
WHERE table_schema='public' AND table_type='BASE TABLE'
이것은 작동합니다!
참고 URL : https://stackoverflow.com/questions/14730228/postgresql-query-to-list-all-table-names
반응형
'Programming' 카테고리의 다른 글
C ++ 코드 / 프로젝트에서 메모리 누수를 찾는 방법은 무엇입니까? (0) | 2020.06.05 |
---|---|
CSS를 사용하여 요소 앞에 줄 바꿈을 삽입하는 방법 (0) | 2020.06.05 |
virtualenv 폴더 이름을 바꾸지 않고 이름 바꾸기 (0) | 2020.06.05 |
build.gradle에서 기본적으로 Android Studio는 어떤 제품 맛을 빌드합니까? (0) | 2020.06.05 |
상태가 검토 대기중인 2 진 거부 (2 진 거부 단추를 찾을 수 없음) (0) | 2020.06.05 |