drop-table
How to completely uninstall a Django app?
Django < 1.7 has a handy management command that will give you the necessary SQL to drop all the tables for an app. See the sqlclear docs for more information. Basically, running ./manage.py sqlclear my_app_name gets you get the SQL statements that should be executed to get rid of all traces of the app in … Read more
How to delete a table in SQLAlchemy?
Just call drop() against the table object. From the docs: Issue a DROP statement for this Table, using the given Connectable for connectivity. In your case it should be: User.__table__.drop() If you get an exception like: sqlalchemy.exc.UnboundExecutionError: Table object ‘my_users’ is not bound to an Engine or Connection. Execution can not proceed without a database … Read more
Can’t drop table: A foreign key constraint fails
This should do the trick: SET FOREIGN_KEY_CHECKS=0; DROP TABLE bericht; SET FOREIGN_KEY_CHECKS=1; As others point out, this is almost never what you want, even though it’s whats asked in the question. A more safe solution is to delete the tables depending on bericht before deleting bericht. See CloudyMarble answer on how to do that. I … Read more
Drop multiple tables in one shot in MySQL
We can use the following syntax to drop multiple tables: DROP TABLE IF EXISTS B,C,A; This can be placed in the beginning of the script instead of individually dropping each table.
DROP IF EXISTS VS DROP?
Standard SQL syntax is DROP TABLE table_name; IF EXISTS is not standard; different platforms might support it with different syntax, or not support it at all. In PostgreSQL, the syntax is DROP TABLE IF EXISTS table_name; The first one will throw an error if the table doesn’t exist, or if other database objects depend on … Read more
SQL DROP TABLE foreign key constraint
No, this will not drop your table if there are indeed foreign keys referencing it. To get all foreign key relationships referencing your table, you could use this SQL (if you’re on SQL Server 2005 and up): SELECT * FROM sys.foreign_keys WHERE referenced_object_id = object_id(‘Student’) and if there are any, with this statement here, you … Read more
Rails DB Migration – How To Drop a Table?
You won’t always be able to simply generate the migration to already have the code you want. You can create an empty migration and then populate it with the code you need. You can find information about how to accomplish different tasks in a migration here: http://api.rubyonrails.org/classes/ActiveRecord/Migration.html More specifically, you can see how to drop … Read more