📜  如何在 postgresql 代码示例中删除所有表

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

代码示例4
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 $$ ;