drop-table

What happens to dependent triggers when the table is dropped?

让人想犯罪 __ 提交于 2019-12-02 06:23:18
问题 I have one table backup on which I had applied one trigger upd_trig . Now, I dropped my table and then I checked, whether all the associated trigger/index will also been dropped or will remain there. As I found some discussion here,and they said Trigger/Index all will be dropped,once we drop our table. But, it seems, trigger still exist. Can anyone explain, what exactly happens, when we drop the table SQL> drop table backup; Table dropped. SQL> select text from user_source; TEXT -------------

Drop table from oracle database if table exist in sql statement [duplicate]

本秂侑毒 提交于 2019-12-02 05:31:23
问题 This question already has answers here : Oracle: If Table Exists (15 answers) Closed 5 years ago . I have to use an SQL statement to drop a table, it will crash if the table doesn't exist. Is it possible to use IF statement to drop the table s.executeUpdate("DROP TABLE employee"); 回答1: Oracle does not support a construct like drop table if exists my_table , which is apparently legal syntax in MySQL (and possibly other RDBMSs). In a .SQL script, where you're running DDL to DROP and/or CREATE

How to delete all tables with prefix “bkp” from a given database?

懵懂的女人 提交于 2019-12-02 02:55:30
问题 I have a SQL server 2005. In that server I have 3 databases -> a,b,c. If I want to delete tables Tables only from database "c". The table's name should start with "bkp" Table should be created one day before. 回答1: Try this: USE C GO SELECT 'DROP TABLE ' + name FROM sys.tables WHERE create_date >= '20101211' -- substitute your date you're interested in AND name like 'bkp%' This will create as output a list of DROP TABLE:.... statement - copy those and paste them into a new SSMS window and

How to delete all tables with prefix “bkp” from a given database?

你离开我真会死。 提交于 2019-12-02 01:24:57
I have a SQL server 2005. In that server I have 3 databases -> a,b,c. If I want to delete tables Tables only from database "c". The table's name should start with "bkp" Table should be created one day before. Try this: USE C GO SELECT 'DROP TABLE ' + name FROM sys.tables WHERE create_date >= '20101211' -- substitute your date you're interested in AND name like 'bkp%' This will create as output a list of DROP TABLE:.... statement - copy those and paste them into a new SSMS window and execute those - and you're done! 来源: https://stackoverflow.com/questions/4424038/how-to-delete-all-tables-with

What happens to dependent triggers when the table is dropped?

馋奶兔 提交于 2019-12-02 00:47:22
I have one table backup on which I had applied one trigger upd_trig . Now, I dropped my table and then I checked, whether all the associated trigger/index will also been dropped or will remain there. As I found some discussion here ,and they said Trigger/Index all will be dropped,once we drop our table. But, it seems, trigger still exist. Can anyone explain, what exactly happens, when we drop the table SQL> drop table backup; Table dropped. SQL> select text from user_source; TEXT ---------------------------------------------------------------------------------------------------- TRIGGER "BIN

How to delete a table in SQLAlchemy?

那年仲夏 提交于 2019-11-28 17:13:44
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() method: sql = text('DROP TABLE IF EXISTS my_users;') result = engine.execute(sql) However, I wonder if there is some standard way to do so. The only one I could find is drop_all() , but it deletes all the structure, not only one specific table: Base.metadata.drop_all(engine) # all tables are deleted For example, given this very basic example. It

Can't drop table: A foreign key constraint fails

主宰稳场 提交于 2019-11-28 16:58:47
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 drop this table? 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.

DROP IF EXISTS VS DROP?

喜夏-厌秋 提交于 2019-11-28 15:26:17
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 use DROP IF EXISTS [TABLE_NAME] it says bad SQL grammar. Can some one help? 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

SQL DROP TABLE foreign key constraint

十年热恋 提交于 2019-11-27 16:45:36
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 OBJECT_ID('dbo.[Student]','U') IS NOT NULL DROP TABLE dbo.[Student] marc_s 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

Can't drop table: A foreign key constraint fails

冷暖自知 提交于 2019-11-27 09:57:45
问题 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 drop this table? 回答1: 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