Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to drop all tables in sql

USE Databasename

SELECT  'DROP TABLE [' + name + '];'
FROM    sys.tables
Comment

drop all tables

DROP DATABASE db_name;
CREATE DATABASE db_name;
Comment

SQL Query to delete all the tables in a database

BY LOVE

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
DECLARE @sql NVARCHAR(max)=''

SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; '
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_TYPE = 'BASE TABLE'
Exec Sp_executesql @sql
Comment

sql drop all tables

DECLARE @sql NVARCHAR(max)=''

SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; '
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_TYPE = 'BASE TABLE'

Exec Sp_executesql @sql
Comment

SQL DROP TABLE Statement

DROP TABLE my_table;
Comment

PREVIOUS NEXT
Code Example
Sql :: GUI for sqlite mac 
Sql :: create-table 
Sql :: pgadmin check database 
Sql :: sqlite clear console 
Sql :: sql highest salary by location 
Sql :: forgot postgres password 
Sql :: sql server find all referencing objects to user-defined table type 
Sql :: TRIGGER AFTER 
Sql :: sql trying to delete database in use 
Sql :: how to check last index rebuild sql server 
Sql :: mdl ddl acl 
Sql :: what is truncate in sql 
Sql :: date datatype in livesql 
Sql :: sql server fn_dblog 
Sql :: in in sql 
Sql :: sql field equals multiple values 
Sql :: stuff in sql server 
Sql :: left join sql 
Sql :: mysql varchar length 
Sql :: insert or update cassandra 
Sql :: compound trigger oracle 
Sql :: List MySQL Table and Index Size 
Sql :: psql invalid command N 
Sql :: Order of execution SQL or MySql query Or Logical order of operations: 
Sql :: SQL Switch Databases 
Sql :: mysql copy data from one table to another 
Sql :: postgresql fastapi sqlmodel example 
Sql :: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , , = or when the subquery is used as an expression. 
Sql :: how to left join a sub query in postgresql 
Sql :: Insert Multiple Rows at Once in SQL 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =