Questions tagged [drop-table]

The SQL command for deleting an entire table.

DROP TABLE is used in SQL to remove a table.

152 questions
578
votes
24 answers

Rails DB Migration - How To Drop a Table?

I added a table that I thought I was going to need, but now no longer plan on using it. How should I remove that table? I've already run migrations, so the table is in my database. I figure rails generate migration should be able to handle this, but…
193
votes
17 answers

SQL DROP TABLE foreign key constraint

If I want to delete all the tables in my database like this, will it take care of the foreign key constraint? If not, how do I take care of that first? GO IF OBJECT_ID('dbo.[Course]','U') IS NOT NULL DROP TABLE dbo.[Course] GO IF…
user188229
184
votes
5 answers

DROP IF EXISTS VS DROP?

Can someone tell me if there is any difference between DROP IF EXISTS [TABLE_NAME] DROP [TABLE_NAME] I am asking this because I am using JDBC template in my MVC web application. If I use DROP [TABLE_NAME] the error said that Table exist. And if I…
AbdulAziz
  • 5,868
  • 14
  • 56
  • 77
160
votes
7 answers

How to completely uninstall a Django app?

What is the procedure for completely uninstalling a Django app, complete with database removal?
zer0stimulus
  • 22,306
  • 30
  • 110
  • 141
151
votes
4 answers

Drop multiple tables in one shot in MySQL

How to drop multiple tables from one single database at one command. something like, > use test; > drop table a,b,c; where a,b,c are the tables from database test.
Krunal
  • 2,061
  • 3
  • 13
  • 13
89
votes
6 answers

Can't drop table: A foreign key constraint fails

In MySQL I want to drop a table. I tried a lot things but I keep getting the error that the table named bericht can't be dropped. This is the error I'm getting: #1217 - Cannot delete or update a parent row: a foreign key constraint fails How do I…
roy
  • 901
  • 1
  • 6
  • 4
87
votes
5 answers

How to delete a table in SQLAlchemy?

I want to delete a table using SQLAlchemy. Since I am testing over and over again, I want to delete the table my_users so that I can start from scratch every single time. So far I am using SQLAlchemy to execute raw SQL through the engine.execute()…
fedorqui
  • 275,237
  • 103
  • 548
  • 598
31
votes
5 answers

Android SQLite Database, WHY drop table and recreate on upgrade

In the tutorials I am following and a lot of more places I see this, onUpgrade -> drop table if exists, then recreate table. What is the purpose of this? private static class DbHelper extends SQLiteOpenHelper{ public DbHelper(Context context)…
Esqarrouth
  • 38,543
  • 21
  • 161
  • 168
28
votes
3 answers

SQL Server: Does 'DROP TABLE' inside transaction causes an implicit commit?

My question is kind of easy but i'm still doubting after I created this transaction. If I execute the following code: BEGIN TRANSACTION DROP TABLE Table_Name Can I perform a ROLLBACK TRANSACTION that recovers the dropped table? I'm asking…
Mauro Bilotti
  • 5,628
  • 4
  • 44
  • 65
22
votes
10 answers

How to drop all tables in database without dropping the database itself?

I would like to delete all the tables from database, but not deleting the database itself. Is it possible ? I'm just looking for shorter way than removing the database and create it again. Thanks !
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
20
votes
6 answers

error in sqlite "DROP TABLE IF EXISTS" android

so i have a problem in my DBAdapter class its just crushes when i try to open the database: from the LogCat i guess the problem is in the onUpgrade function: public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { …
eli
  • 490
  • 1
  • 3
  • 22
18
votes
2 answers

Drop temporary table when exiting a function

I use a temp table in a function with the 'on commit drop' option. My problem is, in certain cases, a more global function can call the first one twice, so the "create temp table" is called twice before the commit - so I have the normal error…
Thomas Perrin
  • 675
  • 1
  • 8
  • 24
16
votes
2 answers

Drop all tables sql developer

I have tables that names start with "TBL_*", but I can not drop all of them by single command. how can I drop this tables?
E A
  • 995
  • 1
  • 10
  • 24
15
votes
6 answers

Dropping a table in SAS

What is the most efficient way to drop a table in SAS? I have a program that loops and drops a large number of tables, and would like to know if there is a performance difference between PROC SQL; and PROC DATASETS; for dropping a single table at a…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
15
votes
3 answers

Avoid exclusive access locks on referenced tables when DROPping in PostgreSQL

Why does dropping a table in PostgreSQL require ACCESS EXCLUSIVE locks on any referenced tables? How can I reduce this to an ACCESS SHARED lock or no lock at all? i.e. is there a way to drop a relation without locking the referenced table? I can't…
Dave
  • 44,275
  • 12
  • 65
  • 105
1
2 3
10 11