Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server constraint is “not trusted”

Tags:

sql-server

I recently heard the term “not trusted”:

SQL Server will mark the constraint as “not trusted”.

Does anyone can explain a bit what is the meaning of that? I know the question is a bit vague but I was wondering if this is a Microsoft specific "term" or is also used by other relational databases?

like image 978
koninos Avatar asked Sep 16 '25 06:09

koninos


1 Answers

If you disable a constraint and then enable it again without specifying the WITH CHECK option then SQL Server will mark that constraint as "not trusted" since it can no longer rely on the existence of the constraint to guarantee that the data is consistent with the constraint conditions. This results in the constraint being ignored for the purposes of execution plans, so the best practice is to always use WITH CHECK when re-enabling constraints.

like image 114
Nathan Griffiths Avatar answered Sep 17 '25 21:09

Nathan Griffiths



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!