Questions tagged [sql-drop]

`DROP` is a keyword in sql. It is used for dropping tables, triggers, schema, procedure etc.

DROP keyword is used for dropping tables, triggers, schema, procedure etc.

Sample code:

DROP TABLE tableName;

Reference

159 questions
561
votes
27 answers

MySQL DROP all tables, ignoring foreign keys

Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there?
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
410
votes
16 answers

Oracle: If Table Exists

I'm writing some migration scripts for an Oracle database, and was hoping Oracle had something similar to MySQL's IF EXISTS construct. Specifically, whenever I want to drop a table in MySQL, I do something like DROP TABLE IF EXISTS…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
235
votes
5 answers

How to remove all MySQL tables from the command-line without DROP database permissions?

How do I drop all tables in Windows MySQL, using command prompt? The reason I want to do this is that our user has access to the database drops, but no access to re-creating the database itself, for this reason we must drop the tables manually. Is…
Mantas
  • 3,179
  • 4
  • 20
  • 32
180
votes
9 answers

How to drop all user tables?

How can I drop all user tables in oracle? I have problem with constraints. When I disable all it is still no possible.
szaman
  • 6,666
  • 13
  • 53
  • 81
162
votes
7 answers

Force drop mysql bypassing foreign key constraint

I'm trying to delete all tables from a database except one, and I end up having the following error: Cannot delete or update a parent row: a foreign key constraint fails Of course I could trial and error to see what those key constraints are and…
johnnyArt
  • 4,327
  • 5
  • 29
  • 28
146
votes
10 answers

How to drop unique in MySQL?

Create Table: CREATE TABLE `fuinfo` ( `fid` int(10) unsigned NOT NULL, `name` varchar(40) NOT NULL, `email` varchar(128) NOT NULL, UNIQUE KEY `email` (`email`), UNIQUE KEY `fid` (`fid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 I want to drop…
Mask
  • 33,129
  • 48
  • 101
  • 125
116
votes
10 answers

SQL: deleting tables with prefix

How to delete my tables who all have the prefix myprefix_? Note: need to execute it in phpMyAdmin
Deniz Zoeteman
  • 9,691
  • 26
  • 70
  • 97
101
votes
6 answers

How to drop all NOT NULL constraints from a PostgreSQL table in one go

Is it possible to drop all NOT NULL constraints from a table in one go? I have a big table with a lot of NOT NULL constraints and I'm searching for a solution that is faster than dropping them separately.
Stefan
  • 1,383
  • 2
  • 15
  • 25
60
votes
3 answers

Does dropping a table in MySQL also drop the indexes?

It's not explicitly mentioned in the documentation (http://dev.mysql.com/doc/refman/6.0/en/drop-table.html). I ask because I just saw a curious database migration in a Rails project where the developer was removing all the indexes before dropping…
Teflon Ted
  • 8,696
  • 19
  • 64
  • 78
53
votes
5 answers

ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost'

I have created a user in mysql. Now i want to delete the user ? How to do that? I am getting this error : ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost' I am using this command : DROP USER 'user'@'localhost'; Its an amazon…
user3086014
  • 4,241
  • 5
  • 27
  • 56
43
votes
4 answers

What happens to index once the table got dropped?

After dropping the table, found that the index created on the columns of the dropped table is gone. I just want to know what happens after that. Could someone please explain? What all are the others getting dropped along with table drop?
Vaandu
  • 4,857
  • 12
  • 49
  • 75
41
votes
6 answers

What is the syntax to drop a Stored Procedure in SQL Server 2000?

Simple question, as the title suggests: What is the syntax to drop a Stored Procedure (SP) in SQL Server 2000, by first checking that the SP exists? Please provide the full code.
Saajid Ismail
  • 8,029
  • 11
  • 48
  • 56
40
votes
6 answers

MySQL bulk drop table where table like?

DROP TABLE ( SELECT table_name FROM information_schema.`TABLES` WHERE table_schema = 'myDatabase' AND table_name LIKE BINARY 'del%'); I know this doesn't work! What is the equivalent for something like this in SQL? I can whip out a simple Python…
ThinkCode
  • 7,841
  • 21
  • 73
  • 92
39
votes
2 answers

Cannot create a new table after "DROP SCHEMA public"

Since I wanted to drop some tables and somebody suggested the below and I did it: postgres=# drop schema public cascade; DROP SCHEMA postgres=# create schema public; CREATE SCHEMA Then I got problem when creating a new database, such as: postgres=#…
user1342336
  • 967
  • 2
  • 16
  • 28
36
votes
3 answers

How to drop multiple databases in SQL Server

Just to clarify, ths isn't really a question, more some help for people like me who were looking for an answer. A lot of applications create temp tables and the like, but I was surprised when Team Foundation Server created 80+ databases on my test…
Gargravarr
  • 635
  • 2
  • 10
  • 18
1
2 3
10 11