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
7
votes
2 answers

How to drop multiple tables having foreign keys in PostgreSQL?

I know syntax for deleting multiple tables is: DROP TABLE foo, bar, baz; But in my case 3 tables having foreign keys in between them and with other tables which are not to be deleted. Table1: Foreign keys From Table2, Table3, 3 more tables in…
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
6
votes
1 answer

Can I drop table using hibernate native SQL query

I am trying to drop the temp table using hibernate native SQL (createSQLQuery) statement. Here is code: session.createSQLQuery("DROP TABLE tmp_dummy_table").executeUpdate(); However It throws me below exception: SQL Error: 1003, SQLState:…
sun2
  • 1,118
  • 1
  • 13
  • 17
6
votes
3 answers

SQLite Drop and Recreate Table

How do I drop and recreate a table with updated information? For example; I have a table in my application with 5 records. ID Entry 1 a 2 b 3 c 4 d 5 e Now when I delete a record lets say, ID 3 the table becomes ID …
Pztar
  • 4,274
  • 6
  • 33
  • 39
6
votes
1 answer

How to reuse the Unused columns again in oracle DB

I have a table with 4 column, ID, NAME,AGE and COUNTRY. For some time being purpose i have set my AGE column as unused by below command alter table Personal set unused column AGE; Now i want to use the same column AGE again, How to do this in…
Mohan
  • 3,893
  • 9
  • 33
  • 42
6
votes
0 answers

sqlite drop index very slow

I have a sqlite database which is about 75 GB. It takes almost 4 hours to create an index on the database. After indexing, the file size is about 100 GB. Often, I have to modify (insert/delete/update) large chunks (few GBs) of data. As of now, I am…
Santosh Tiwari
  • 1,167
  • 2
  • 14
  • 26
5
votes
1 answer

Drop index query is slow

This is the query I'm trying to execute: DROP INDEX id_index on table; I've been able to drop indexes quickly in the past, but this query ran for almost an hour before I gave up on it. What could be causing this slow pace?
Garrett
  • 89
  • 1
  • 1
  • 5
5
votes
4 answers

DROP TABLE fails for temp table

I have a client application that creates a temp table, the performs a bulk insert into the temp table, then executes some SQL using the table before deleting it. Pseudo-code: open connection begin transaction CREATE TABLE #Temp ([Id] int NOT…
StarBright
  • 161
  • 1
  • 1
  • 5
5
votes
2 answers

Drop normal or materialized view in Postgresql 9.3 in one query

I’ve got a view in my PostgreSQL, which can be both normal or materialized, depending on some circumstances. I'm trying to write a query that would drop the view for sure and with no errors no matter what type it has got at the moment. However, this…
Alexander Kachkaev
  • 842
  • 15
  • 29
5
votes
1 answer

WordPress Plugin Development - Can't drop database table after plugin deactivation?

I am trying to drop the database table created when my custom plugin is activated. I am using basically the same code, just a drop query. However, the table won't drop! I have confirmed the following: The WP Database User has privileges to drop…
JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
5
votes
1 answer

Mysql "drop function if exists" fails with code 1305

When I try to execute the code bellow I get mysql error 1305: DROP FUNCTION IF EXISTS myFunction; It only fails when function does not exist. But why? Isn't that the cleanup step before you re-create functions?
Borut Tomazin
  • 8,041
  • 11
  • 78
  • 91
5
votes
2 answers

mysql drop table if exists inside procedure

I'm trying to apply a nested set model example with procedures. I've found many of them with this technique and in the process I've found a problem. Every time I call the procedure I get unknown table XXX. When I create the procedure I got no…
Alwin Kesler
  • 1,450
  • 1
  • 20
  • 41
5
votes
3 answers

Is there a simpler and faster way of dropping a table that has foreign key references to other tables?

I have a new table that has foreign key references to a number of existing tables. When I create the new table for the first time, I created the foreign keys in the following way: ALTER TABLE [dbo].[NewTable] WITH CHECK ADD FOREIGN…
crazyTech
  • 1,379
  • 3
  • 32
  • 67
5
votes
1 answer

how to drop a replicated table in both the publication and subscription

How do I drop a replicated table in the publication as well as the subscription? (scripts only) I do not want to remove it from replication only, because then an unreplicated copy of the table will remain on the subscriptions. I want all instances…
hofnarwillie
  • 3,563
  • 10
  • 49
  • 73
4
votes
1 answer

Oracle Security - how to prevent a User from DROP TABLE its own tables

As security tightening exercise, I'm removing all system privileges from an oracle database user. Now this user ONLY has the following system privileges: CREATE SESSION UNLIMITED TABLESPACE I was hoping that the user wont be able to do any DDL…
Tyn
  • 555
  • 7
  • 22
4
votes
1 answer

MySql - DROP table 'whatever' if exist ELSE create table 'whatever'?

I simply want to drop the table 'whatever' if it exist and then recreate table 'whatever' in a single query if possible. DROP TABLE IF EXISTS `whatever` ELSE CREATE TABLE `whatever` Any idea ?
capte
  • 207
  • 1
  • 3
  • 9
1 2
3
10 11