简体   繁体   English

如何在 SQL Server 中删除带有外键约束的表

[英]How to drop a table with foreign key constraint in SQL Server

I would like to drop a table with foreign key constraint and re-create the same table (with all the relationships) and with additional data (which I have from “Generate Scripts…”)我想删除一个带有外键约束的表并重新创建同一个表(包含所有关系)和附加数据(我从“生成脚本...”中获得)

How can I do it?我该怎么做? I'm using an Azure SQL Server.我正在使用 Azure SQL Server。

If I disable the constraint, truncate the table, insert new data, and re-enable it?如果我禁用约束,截断表,插入新数据,然后重新启用它? Will this work?这会起作用吗?

Any leads, please?请问有什么线索吗? Thanks.谢谢。

One of the ways is to create a .sqlproj .其中一种方法是创建一个.sqlproj Inside this, you can create the tables, stored procedures, indexes, data population, and much more.在其中,您可以创建表、存储过程、索引、数据填充等等。 The deployment from .sqlproj will take care of any changes you do to the data store. .sqlproj的部署将处理您对数据存储所做的任何更改。 Please refer to the links below.请参考以下链接。

URL: https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/azure-sqldb?view=azure-devops&tabs=yaml网址: https : //docs.microsoft.com/en-us/azure/devops/pipelines/targets/azure-sqldb?view=azure-devops&tabs=yaml

https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-ver15 https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-ver15

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将外键约束添加到引用两个表B或B的两个表中的表A(ID,类型)? - How to add foreign key constraint to Table A (id, type) referencing either of two tables Table B (id, type) or Table C (id, type)? 为什么在将 2 个表的关系输入到关系表中时出现外键约束错误? - Why am I getting a foreign key constraint error when entering a relation of 2 tables with data present into a relationship table? SQL Azure联合身份验证的外键约束是否需要实际约束? - Does foreign key constraints for sql azure federations need tenantid in the actual constraint? 审计表和外键 - Audited table and foreign key 如何在SQL Azure中使用外键约束从表中清除数据 - How to clear data from tables with foreign key contraints in SQL Azure 如何在SQL Azure中设置外键? - How do you set up a foreign key in SQL Azure? 从 Azure SQL 导出数据后如何添加主键和外键约束 - How can I add primary key and foreign key constraints after export data from Azure SQL SQL Server使用没有主键的聚簇索引创建表 - SQL Server creating table with clustered index without a primary key 复合聚集索引作为主键与SQL Server中的堆表 - Composite clustered index as primary key vs heap table in SQL Server 无法删除SQL天蓝色表 - Unable to drop SQL azure table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM