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 :: postgresql calculate age from birthdate 
Sql :: find largest table in mysql database 
Sql :: sql drop procedure if exists 
Sql :: how to remove tables from postgresql 
Sql :: mysql change database charset and collation 
Sql :: oracle to_timestamp 
Sql :: sql server check version 
Sql :: sql add days to date 
Sql :: update part of a string in mysql 
Sql :: postgres regex remove special characters 
Sql :: sql server last executed query 
Sql :: postgres delete from where date is greater than specific date 
Sql :: find table from column name in sql 
Sql :: rename column postgres 
Sql :: how to group by month using sql server 
Sql :: mssql show database size 
Sql :: oracle first day of last year 
Sql :: alter sequence postgres 
Sql :: mysql concat two columns laravel eloquent 
Sql :: oracle create schema 
Sql :: command line mysql import 
Sql :: update mysql centos 
Sql :: mysql format date 
Sql :: oracle sql query to make column data uppercase 
Sql :: psql restore from tar 
Sql :: add many column to sap iq table 
Sql :: postgresql random number 
Sql :: function difference_in_hours(timestamp with time zone) does not exist 
Sql :: list all tables and columns in postgresql 
Sql :: oracle plan hash value 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =