📜  postgres 删除所有表 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:25.761000             🧑  作者: Mango

代码示例3
DO $$ 
  DECLARE 
    r RECORD;
BEGIN
  FOR r IN 
    (
      SELECT table_name 
      FROM information_schema.tables 
      WHERE table_schema=current_schema()
    ) 
  LOOP
     EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.table_name) || ' CASCADE';
  END LOOP;
END $$ ;