Sql Server: What is the benefit of using “Enforce foreign key constraint” when it's set to “NO”?



I know the purpose of "Enforce foreign key constraint" in RDBMS. But is there any benefit when it's set to "NO" ?


In normal production, this setting should never be set to NO.

But: when you're developing, or restructuring a database, or when you do e.g. a large bulk load of data that you'll need to "sanitize" (clean up), then it can make sense to turn off foreign key constraints to allow "non-valid" data to be loaded into a table. Of course, as I said - you shouldn't keep that setting turned off for a long period of time - you should then proceed to clean up the data, either delete those rows that are in violation of the FK constraint, or update their values so they match a parent row.
So again: in "normal" production mode, this setting should never be NO - but for specific tasks, it might help get the job done more easily. Use it with caution, and always turn the FK constraints back on as soon as you can!

原文链接

SQL Server数据库中外键强制约束的好处是什么,什么时候设置外键非强制约束?(转载)的更多相关文章

  1. 何查询SQL Server数据库没有主键的表并增加主键

    SQL Server数据库中,如果一个表没有主键,我们该如何查询呢?本文我们主要就介绍了如何查询数据库中没有主键的表名并为其增加主键的方法,希望能够对您有所帮助. 该功能的实现代码如下: declar ...

  2. SQL Server数据库中导入导出数据及结构时主外键关系的处理

    2015-01-26 软件开发中,经常涉及到不同数据库(包括不同产品的不同版本)之间的数据结构与数据的导入导出.处理过程中会遇到很多问题,尤为突出重要的一个问题就是主从表之间,从表有外检约束,从而导致 ...

  3. SQL Server数据库学习笔记-外键

    关于主键的话大家很好理解,主键的主要作用就是用来标识一条数据是唯一的,也就是保证数据的实体完整性.防止数据重复.但是外键的话就有许多的疑问了,那外键是咋回事儿呢? 1. 外键的定义: 外键(FK)是用 ...

  4. 5、SQL Server数据库、T-SQL

    SQL Server数据库基础 一.安装SQL Server数据库 setup.exe->安装->全新SQL Server独立安装或向现有安装添加功能->输入序列号->下一步- ...

  5. SQL Server - 数据库初识

      在互联网笔试中,常遇到数据库的问题,遂来简单总结,注意,以 Sql Server 数据库为例. 数据库 数据库系统,Database System,由数据库和数据库管理系统组成. 数据库,Data ...

  6. 转载 50种方法优化SQL Server数据库查询

    原文地址 http://www.cnblogs.com/zhycyq/articles/2636748.html 50种方法优化SQL Server数据库查询 查询速度慢的原因很多,常见如下几种: 1 ...

  7. Microsoft SQL Server 数据库 错误号大全

    panchzh :Microsoft SQL Server 数据库 错误号大全0 操作成功完成. 1 功能错误. 2 系统找不到指定的文件. 3 系统找不到指定的路径. 4 系统无法打开文件. 5 拒 ...

  8. SQL Server数据库、表、数据类型基本概念

    一.SQL Server的数据存储结构 SQL Server是一个数据库管理系统,需要以有效方式存储高容量数据.要更好地理解SQL Server处理数据的方式,就需要了解数据的存储结构. 1.文件类型 ...

  9. SQL Server数据库设计规范

    数据库设计规范 1.简介 数据库设计是指对一个给定的应用环境,构造最优的数据库模式,建立数据库及其他应用系统,使之能有效地存储数据,满足各种用户的需求.数据库设计过程中命名规范很是重要,命名规范合理的 ...

随机推荐

  1. Wookmark-jQuery-master 瀑布流插件使用介绍,含个人测试DEMO

    要求 必备知识 本文要求基本了解 Html/CSS,  JavaScript/JQuery. 开发环境 Dreamweaver CS6 / Chrome浏览器 演示地址 演示地址 资料下载   测试预 ...

  2. 【详解】核心组件之UserDetailService

    简介 UserDetails => Spring Security基础接口,包含某个用户的账号,密码,权限,状态(是否锁定)等信息.只有getter方法. Authentication => ...

  3. 逆向工程-对native层的一次简单逆向实践

    关注一款app很久了,这款app为了防止别人逆向破解拉取数据做了很多工作: 防止别人修改apk包,执行关键动作时对dex文件进行md5验证: 防止用户调用接口批量拉数据,对返回的web网页里个人信息进 ...

  4. HDU 1242 Rescue(BFS+优先队列)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1242 题目描述: Problem Description Angel was caught by t ...

  5. 【SpringBoot系列2】SpringBoot整合Redis

    前言: 真的越来越喜欢SpringBoot了,这是SpringBoot学习系列之一. 正文: 1:首先在pom文件中添加依赖,记得是spring-boot-starter-data-redis,不是s ...

  6. UIKit框架之NSObject

    首先学习NSObject // // ViewController.m // localization // // Created by City--Online on 15/5/15. // Cop ...

  7. 自定义MVC的Helper扩展方法

    记得在开发ASP.NET时候,也经常性使用C#可以写自己义的扩展方法,如:http://www.cnblogs.com/insus/p/3154363.html 或http://www.cnblogs ...

  8. Jquery操作属性

    1.attr(name,value):修改单个属性! name :属性名称 value:属性的值 <script> $(function(){ //给div添加一个alt=hello的属性 ...

  9. [C#]非阻塞监听键盘输入

    摘要 最近需要调研监控用户键盘输入的内容,然后收集数据进行用户行为分析.然后就用控制台程序弄了一个demo. 代码如下 class Program { static void Main(string[ ...

  10. Fragment的坑

    http://www.jianshu.com/p/d9143a92ad94 使用add()加入fragment时将触发onAttach(),使用attach()不会触发onAttach() 使用rep ...