sql-server – 删除外键而不知道约束的名称?
发布时间:2020-12-12 16:42:58 所属栏目:MsSql教程 来源:网络整理
导读:我使用以下命令创建了一个表: create table Table1( Id int Not Null Foreign key references Table2(Id) on delete cascade on update cascade,UserName nvarchar(150),TimeInSeconds int Not Null primary key(Id,TimeInSeconds)); 但现在我想放掉外键. 因
我使用以下命令创建了一个表:
create table Table1( Id int Not Null Foreign key references Table2(Id) on delete cascade on update cascade,UserName nvarchar(150),TimeInSeconds int Not Null primary key(Id,TimeInSeconds) ); 但现在我想放掉外键. Alter table <tablename> drop foreign key <foreign key name> 有什么办法吗请帮忙 解决方法您可以在INFORMATION_SCHEMA.TABLE_CONSTRAINTS中找到约束的名称select CONSTRAINT_NAME from INFORMATION_SCHEMA.TABLE_CONSTRAINTS where TABLE_NAME = 'Table1' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- sql-server – SQL Server:获取应用程序的名称,导致触发器
- sql – LISTAGG等效于windowing子句
- sqlserver2000字符串函数(上)
- 配置 – 无人参与安装MS SQL Server(2008 | 2012)EXPRESS?
- MSSQL修改用户账户密码
- SQLServer 报错:用户、组或角色'XXX' 在当前数据库
- MySQL中表复制:create table like 与 create table as sele
- 数据库 – 维护客户帐户余额的最佳方式
- sql-server – SQL Server中的时间格式
- sql server 过滤重复数据的简单示例