DROP ALL TABLES IN A SCHEMA

While there isn’t a single command to drop all tables in a schema, you can easily accomplish that task by generating and then executing DROP TABLE commands for each table.

Example:

				
					[root@localhost bin]# ysqlsh -c "\dt public.*"
                List of relations
 Schema |        Name         | Type  |  Owner
--------+---------------------+-------+----------
 public | ysql_bench_accounts | table | yugabyte
 public | ysql_bench_branches | table | yugabyte
 public | ysql_bench_history  | table | yugabyte
 public | ysql_bench_tellers  | table | yugabyte
(4 rows)

[root@localhost bin]# ysqlsh -Atc "SELECT 'DROP TABLE IF EXISTS ' || schemaname || '.' || tablename || ';' AS ddl FROM pg_tables WHERE schemaname = 'public';" | ysqlsh
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE

[root@localhost bin]# ysqlsh -c "\dt public.*"
Did not find any relation named "public.*".
				
			

Have Fun!