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

SQL Server: drop table cascade equivalent?

In oracle, to drop all tables and constraints you would type something like DROP TABLE myTable CASCADE CONSTRAINTS PURGE; and this would completely delete the tables and their dependencies. What's the SQL server equivalent??
Sinaesthetic
  • 11,426
  • 28
  • 107
  • 176
31
votes
5 answers

How do I drop a column with object dependencies in SQL Server 2008?

The error message I'm obtaining when trying to drop a column: The object 'defEmptyString' is dependent on column 'fkKeywordRolleKontakt'. Msg 5074, Level 16, State 1, Line 43 ALTER TABLE DROP COLUMN fkKeywordRolleKontakt failed because one or more…
Simon A. Eugster
  • 4,114
  • 4
  • 36
  • 31
30
votes
2 answers

PostgreSQL drop role fails because of default privileges

I am trying to drop a role 'xyz' that was previously the owner of the schema with the same name 'xyz'. I altered the schema ownership as below, and run reassigned ownership just in case (although all tables were created by a different user with…
Ruxandra Palmtag
  • 383
  • 2
  • 4
  • 5
23
votes
3 answers

Postgresql - Why is DROP VIEW command hanging?

I want to perform a simple DROP VIEW ... but it hangs. I have run this query SELECT * FROM pg_locks WHERE NOT granted taken from this page on Lock Monitoring. However the following query they suggest returns no results: SELECT bl.pid AS…
Stephan
  • 41,764
  • 65
  • 238
  • 329
22
votes
6 answers

Delete, Truncate or Drop to clean out a table in MySQL

I am attempting to clean out a table but not get rid of the actual structure of the table. I have an id column that is auto-incrementing; I don't need to keep the ID number, but I do need it to keep its auto-incrementing characteristic. I've found…
Doug Molineux
  • 12,283
  • 25
  • 92
  • 144
20
votes
7 answers

How to drop a list of SQL Server tables, ignoring constraints?

I have a list of half a dozen MSSQL 2008 tables that I would like to remove at once from my database. The data has been entirely migrated to new tables. There is no reference in the new tables to the old tables. The problem being that old tables…
Joannes Vermorel
  • 8,976
  • 12
  • 64
  • 104
16
votes
6 answers

DB2 Drop table if exists equivalent

I need to drop a DB2 table if it exists, or drop and ignore errors.
Roman Iuvshin
  • 1,872
  • 10
  • 24
  • 40
16
votes
1 answer

How to DROP a database with character '?' in its name?

Just trying out ubuntu server on my pc and have been testing some commands including mysql. I'm not sure why phpMyAdmin permitted me to create a database like this 'testing?db'. I'm trying to drop this database via SSH but I get this error: mysql>…
hugseirvak
  • 315
  • 1
  • 2
  • 11
15
votes
1 answer

Unable to drop database due to illegal character

How can i drop a database containing the "-" symbol? mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | vms01 | | vms-0.1.0 …
Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215
12
votes
5 answers

SQL drop table and re-create and keep data

On our original design we screwed up a foreign key constraint in our table. Now that the table is full of data we cannot change it without dropping all of the records in the table. The only solution I could think of is to create a backup table and…
user516883
  • 8,868
  • 23
  • 72
  • 114
9
votes
2 answers

drop index or constraint without knowing its name for Oracle

On a oracle database I have a foreign key, without knowing its name, just the column_name and the reference_column_name. I want to write a sql script which should drop this foreign key if it exists, so this is the code I use: declare fName…
radio
  • 897
  • 2
  • 10
  • 25
9
votes
1 answer

Difference between DROP USER and deleting a row from the mysql.user table

I have a database with hundreds of active connections at any point in time. When I use the DROP USER sql statement to remove a user account, it takes ~4 seconds, during which all other connections have the state "Checking permissions". This means…
BrainCore
  • 5,214
  • 4
  • 33
  • 38
8
votes
3 answers

Can you DROP TABLE IF EXISTS by specifying database name with table?

I am trying to drop a table in a database with the following query statement: mysql_query('DROP TABLE IF EXISTS "dbName.tableName"') or die(mysql_error()); But I keep getting an error. Does anyone know if specifying the dbName.tableName is invalid?
H. Ferrence
  • 7,906
  • 31
  • 98
  • 161
8
votes
1 answer

Dropping a column with a foreign key

On my mysql DB with inno_db engine, I have a table with a foreign key. I want to drop the column (along with the foreign key and the associated index of course - i don't need the whole column!) Now, simply dropping it yields an error: General…
shealtiel
  • 8,020
  • 18
  • 50
  • 82
7
votes
1 answer

Python sqlite3 parameterized drop table

I have a problem with dropping sqlite3 table in python. I am using standard sqlite3 module. self.conn = sqlite3.connect(...) sql = """ drop table ? """ self.conn.execute( sql, (u'table_name',) ) gives me OperationalError: near "?": syntax error…
pajton
  • 15,828
  • 8
  • 54
  • 65
1
2
3
10 11