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 :: use concat in group_concat 
Sql :: mysql separator 
Sql :: sql drop default 
Sql :: sql upsert 
Sql :: lowest salary in sql 
Sql :: DB: in eloquent using sql 
Sql :: rename field name in mysql 
Sql :: select if then postgresql 
Sql :: concatenate two strings in sql 
Sql :: oracle nextval insert 
Sql :: sql get last inserted row 
Sql :: get all columns from table sql 
Sql :: sql update table set text to lowercase 
Sql :: mysql select update same table 
Sql :: mysql replace remove html tag 
Sql :: oracle remove line breaks 
Sql :: postgres show databases 
Sql :: sql convert date to string yyyy-mm-dd 
Sql :: space not removing from column in sql 
Sql :: joomla execute raw sql 
Sql :: SQL Server lock table example 
Sql :: how to select one row in mysql 
Sql :: use float in sql server string 
Sql :: psql select database 
Sql :: sql date format dd-mm-yyyy 
Sql :: json extract 
Sql :: mysql backup database 
Sql :: dual in db2 
Sql :: how to check table name in current database sql 
Sql :: r rmysql connect local database Plugin caching_sha2_password could not be loaded 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =