SQL外键约束
2017-08-30 14:44
134 查看
1.查询表已有的外键
select name from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id where f.parent_object_id=object_id('表名')
2.删除表外键
alter table 表名 drop constraint 外键约束名
3.添加外键
alter table 表名 add constraint 外键约束名 foreign key(列名) references 引用外键表(列名)
相关文章推荐
- SQL2012 设置外键FK约束
- 在创建外键约束的时候, 设置级联删除为SET NULL执行sql语句的时候显示有错误,(数据库为sqlserver2000)?
- sql 外键约束
- SQL 2005 带自增列 带外键约束 数据导入导出
- SQL的主键和外键约束
- SQL的主键和外键约束
- (转)后期加外键约束的sql语句
- SQL脚本创建数据表,并给出主键,外键,唯一键,约束
- sql外键约束NO ACTION,CASCADE,SET NULL,SET DEFAULT
- SQL删除记录中包含外键约束的处理…
- sql外键约束NO ACTION,CASCADE,SET NULL,SET DEFAULT
- SQL WITH NOCHECK 解决外键约束出现的冲突
- sql外键约束
- 设置外键约束的SQL语句:
- 用T-SQL删除数据库表中的外键约束
- SQL的主键和外键约束
- SQL约束(外键、主键、触发器)
- sql 外键约束
- 解除oracle数据库中所有外键约束SQL语句
- SQL的主键和外键约束