티스토리 뷰

Database/PostgreSQL

모든 Table Drop 하기

angieveloper 2022. 8. 21. 08:56

 

select 'drop table if exists "' || tablename || '" cascade;' from pg_tables;

이렇게 해서 출력되는 명령문들 복사해서 입력해서 삭제하기

schema 날려버리는 방법보다 훨씬 안전하고 좋음

 

 

출처 : 

https://stackoverflow.com/questions/3327312/how-can-i-drop-all-the-tables-in-a-postgresql-database

 

How can I drop all the tables in a PostgreSQL database?

How can I drop all tables in PostgreSQL, working from the command line? I don't want to drop the database itself, just all tables and all the data in them.

stackoverflow.com

 

'Database > PostgreSQL' 카테고리의 다른 글

[PostgreSQL] The data directory contains an old postmaster.pid file  (0) 2023.01.30
Create Database  (0) 2022.08.17
Ubuntu 환경에 PostgreSQL 설치  (0) 2022.08.17
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함