Search
 
SCRIPT & CODE EXAMPLE
 

SQL

force drop all tables postgres

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
Comment

how to remove tables from postgresql

DROP TABLE IF EXISTS tablename;
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 :: display 2 numbers after decimal mysql 
Sql :: mysql row_number() example 
Sql :: postgresql find duplicates 
Sql :: update from table tsql 
Sql :: how to truncate table with foreign key constraint postgresql 
Sql :: how to find database collation in postgres 
Sql :: declare variables sql 
Sql :: get date from timestamp oracle 
Sql :: enable constraint in sql 
Sql :: select nextval from sequence oracle 
Sql :: mysql cdn link 
Sql :: pad zero sql server 
Sql :: check if database exists sql 
Sql :: if else in postgresql 
Sql :: show the colums of table sql 
Sql :: create index mysql 
Sql :: oracle list dates without weekends 
Sql :: mysql terminal run sql file 
Sql :: update auto increment value in mysql 
Sql :: mysql backup table 
Sql :: update table disable constraint 
Sql :: how to insert json value in mysql 
Sql :: oracle apex view logs 
Sql :: Select without null values sql 
Sql :: sql select first and last record of each group 
Sql :: change mariadb to mysql xampp 
Sql :: sql row number in result set 
Sql :: activate event scheduler mariadb 
Sql :: rename table sqlite 
Sql :: remove auto increment mysql 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =