In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following to understand the mysql association table deletion method, I believe that we will benefit a lot after reading, the text in the essence is not much, hope that the mysql association table deletion method of this short content is what you want.
1. Delete the foreign key constraint of the table
A foreign key is a special field that associates a table with its parent table. When the table is created, the foreign key constraint is already set. The following statement is needed to remove the relationship between them.
Alter table table name drop foreign key foreign key alias
The foreign key alias parameter refers to the foreign key code that was set when the table was created.
two。 Delete ordinary tables that are not associated
Drop table table name
When you delete a table, all data in the table is also deleted. When deleting a table, it is best to back up the data in the table first.
3. Delete parent tables associated with other tables
When deleting a table about associative relationships, an error will be reported with drop table example1 because there are foreign keys that depend on the table
For example, you create an example4 table that depends on the example1 table, and the foreign key stu_id of the example4 table depends on the primary key of the example1 table. The parent table of the example4 table when the example1 table.
If you want to delete the example4 table, you must first get rid of this dependency. The easiest way is to delete the child table example4 first, and then delete the parent table example1. However, this may affect other data in the child table.
Another way is to first delete the foreign key constraint of the child table, and then delete the parent table. This method will not affect the other data of the child table and can ensure the security of the database.
For example, the foreign key alias of the example4 table is d_fk, and the foreign key constraint of example4 is removed
Alter table example4 drop foreign key dumbfk;.
You can use show create table example4\ G to see if it has been deleted.
Then execute the drop table example1;.
A successful execution indicates a successful operation.
After reading this article on how to delete mysql related tables, many readers will want to know more about it. If you need more industry information, you can follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.