Search
 
SCRIPT & CODE EXAMPLE
 

SQL

force drop all tables postgres

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
Comment

how to drop all tables in postgresql

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;

GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
Comment

postgres drop all tables

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 $$ ;
Comment

PREVIOUS NEXT
Code Example
Sql :: sql server read uncommitted 
Sql :: sql add year to date 
Sql :: how to list columns for particular tables in postgresql 
Sql :: query to list all tables in sql database 
Sql :: mysql command line xampp ubuntu 
Sql :: to date oracle with time 
Sql :: show list of users in mysql 
Sql :: restart postgresql.service Failed to restart postgresql.service: Unit not found. 
Sql :: .... ERROR! The server quit without updating PID file mysql centos 
Sql :: oracle list functions 
Sql :: Found option without preceding group in config file: /etc/mysql/mariadb.conf.d/50-server.cnf at line: 1 
Sql :: Failed to stop mysql.service: Unit mysql.service not loaded. 
Sql :: find table for column name in sql 
Sql :: sql auto update dupdated_at 
Sql :: update with inner join 
Sql :: add sequence postgres 
Sql :: mysql import ignore errors 
Sql :: stop mysql ubuntu 
Sql :: CREATE DATABASE db; SyntaxError: Unexpected identifier 
Sql :: convert epoch to date in sql server 
Sql :: install mysql workbench ubuntu 20.04 terminal 
Sql :: create schema postgres 
Sql :: oracle alter sequence nextval 
Sql :: get current year sql 
Sql :: set statiscis on in sql server 
Sql :: ordering by issue with 4 digit numbers in sql 
Sql :: vagrant mysql downgrade version 
Sql :: create procedure with encryption 
Sql :: mysql full outer join java 
Sql :: sql delete records older than 1 day 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =