๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_check.asp
SQL CHECK Constraint
The CHECK constraint evaluates the data to TRUE or FALSE. If the data evaluates to TRUE, the operation is ok. If the data evaluates to FALSE, the entire INSERT or UPDATE operation is aborted, and an error is raised.
๐ŸŒ
Hightouch
hightouch.com โ€บ sql-dictionary โ€บ sql-check
SQL CHECK - Syntax, Use Cases, and Examples | Hightouch
December 29, 2023 - A CHECK constraint in SQL is a database constraint that specifies a condition that data must meet for an operation to be allowed.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ sql โ€บ relational-databases โ€บ tables โ€บ create-check-constraints
Create check constraints - SQL Server | Microsoft Learn
November 18, 2025 - Learn how to can create a check constraint in a table to specify the data values that are acceptable in one or more columns in the SQL Server Database Engine.
type of integrity constraint in SQL
A check constraint is a type of integrity constraint in SQL which specifies a requirement that must be met by each row in a database table. The constraint must be a predicate. โ€ฆ Wikipedia
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Check_constraint
Check constraint - Wikipedia
January 25, 2025 - A check constraint is a type of integrity constraint in SQL which specifies a requirement that must be met by each row in a database table. The constraint must be a predicate. It can refer to a single column, or multiple columns of the table. The result of the predicate can be either TRUE, ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ sql-check-constraint
SQL CHECK Constraint - GeeksforGeeks
February 10, 2026 - The CHECK constraint in SQL ensures that only valid data enters a column by enforcing specific conditions.
๐ŸŒ
Programiz
programiz.com โ€บ sql โ€บ check
SQL CHECK Constraint (With Examples)
In SQL, the CHECK constraint is used to specify the condition that must be validated in order to insert data into a table.
๐ŸŒ
DB Vis
dbvis.com โ€บ thetable โ€บ sql-check-constraint-definitive-guide-with-examples
SQL CHECK Constraint: Definitive Guide With Examples
December 16, 2024 - In an ALTER TABLE query, it is usually specified at the end, after the column definition. ... The CONSTRAINT [constraint_name] part of the syntax is optional and required to define named constraints as below: ... Otherwise, the database engine will give the CHECK constraint an automatic name, such as t1_c1_check. Typically, SQL CHECK constraints are enforced immediately after they are defined.
๐ŸŒ
W3Schools
w3schools.com โ€บ mysql โ€บ mysql_check.asp
MySQL CHECK Constraint
The CHECK constraint evaluates the data to TRUE or FALSE. If the data evaluates to TRUE, the operation is ok. If the data evaluates to FALSE, the entire INSERT or UPDATE operation is aborted, and an error is raised.
Find elsewhere
๐ŸŒ
MySQL
dev.mysql.com โ€บ doc โ€บ refman โ€บ 8.4 โ€บ en โ€บ create-table-check-constraints.html
MySQL :: MySQL 8.4 Reference Manual :: 15.1.20.6 CHECK Constraints
mysql> SHOW CREATE TABLE t1\G *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` int(11) DEFAULT NULL, `c3` int(11) DEFAULT NULL, CONSTRAINT `c1_nonzero` CHECK ((`c1` <> 0)), CONSTRAINT `c2_positive` CHECK ((`c2` > 0)), CONSTRAINT `t1_chk_1` CHECK ((`c1` <> `c2`)), CONSTRAINT `t1_chk_2` CHECK ((`c1` > 10)), CONSTRAINT `t1_chk_3` CHECK ((`c3` < 100)), CONSTRAINT `t1_chk_4` CHECK ((`c1` > `c3`)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ยท The SQL standard specifies that all types of constraints (primary key, unique index, foreign key, check) belong to the same namespace.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ sql โ€บ relational-databases โ€บ tables โ€บ unique-constraints-and-check-constraints
Unique constraints and check constraints - SQL Server | Microsoft Learn
Unless a clustered index is explicitly specified, a unique, nonclustered index is created by default to enforce the UNIQUE constraint. CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns.
๐ŸŒ
TechOnTheNet
techonthenet.com โ€บ sql_server โ€บ check.php
SQL Server: Check Constraints
This SQL Server tutorial explains how to use the check constraints in SQL Server (Transact-SQL) with syntax and examples. A check constraint in SQL Server (Transact-SQL) allows you to specify a condition on each row in a table.
๐ŸŒ
TutorialsTeacher
tutorialsteacher.com โ€บ sqlserver โ€บ check-constraints
SQL Server Check Constraints: Create, Edit, Enable/Disable
In SQL Server, a check constraint is used to specify the limitation on the values of a column when inserting or updating.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ sql โ€บ sql-check-constraint.htm
SQL - Check Constraint
The SQL CHECK constraint is used to add conditions on a column of a table. Once you add the check constraint on a column, it ensures that the data entered into the column meets the specified conditions.
๐ŸŒ
CockroachDB Docs
cockroachlabs.com โ€บ docs โ€บ stable โ€บ check
CHECK Constraint
The following example specifies the table-level CHECK constraint named ok_to_supply that a quantity_on_hand value must be greater than 0 and a warehouse_id must be between 100 and 200. > CREATE TABLE inventories ( product_id INT NOT NULL, warehouse_id INT NOT NULL, quantity_on_hand INT NOT NULL, PRIMARY KEY (product_id, warehouse_id), CONSTRAINT ok_to_supply CHECK (quantity_on_hand > 0 AND warehouse_id BETWEEN 100 AND 200) );
Top answer
1 of 16
439

try this:

SELECT
    * 
    FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS 
    WHERE CONSTRAINT_NAME ='FK_ChannelPlayerSkins_Channels'

-- EDIT --

When I originally answered this question, I was thinking "Foreign Key" because the original question asked about finding "FK_ChannelPlayerSkins_Channels". Since then many people have commented on finding other "constraints" here are some other queries for that:

--Returns one row for each CHECK, UNIQUE, PRIMARY KEY, and/or FOREIGN KEY
SELECT * 
    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
    WHERE CONSTRAINT_NAME='XYZ'  


--Returns one row for each FOREIGN KEY constrain
SELECT * 
    FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS 
    WHERE CONSTRAINT_NAME='XYZ'


--Returns one row for each CHECK constraint 
SELECT * 
    FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS
    WHERE CONSTRAINT_NAME='XYZ'

here is an alternate method

--Returns 1 row for each CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY, and/or DEFAULT
SELECT 
    OBJECT_NAME(OBJECT_ID) AS NameofConstraint
        ,SCHEMA_NAME(schema_id) AS SchemaName
        ,OBJECT_NAME(parent_object_id) AS TableName
        ,type_desc AS ConstraintType
    FROM sys.objects
    WHERE type_desc LIKE '%CONSTRAINT'
        AND OBJECT_NAME(OBJECT_ID)='XYZ'

If you need even more constraint information, look inside the system stored procedure master.sys.sp_helpconstraint to see how to get certain information. To view the source code using SQL Server Management Studio get into the "Object Explorer". From there you expand the "Master" database, then expand "Programmability", then "Stored Procedures", then "System Stored Procedures". You can then find "sys.sp_helpconstraint" and right click it and select "modify". Just be careful to not save any changes to it. Also, you can just use this system stored procedure on any table by using it like EXEC sp_helpconstraint YourTableNameHere.

2 of 16
328

Easiest way to check for the existence of a constraint (and then do something such as drop it if it exists) is to use the OBJECT_ID() function...

IF OBJECT_ID('dbo.[CK_ConstraintName]', 'C') IS NOT NULL 
    ALTER TABLE dbo.[tablename] DROP CONSTRAINT CK_ConstraintName

OBJECT_ID can be used without the second parameter ('C' for check constraints only) and that may also work, but if your constraint name matches the name of other objects in the database you may get unexpected results.

IF OBJECT_ID('dbo.[CK_ConstraintName]') IS NOT NULL 
    ALTER TABLE dbo.[tablename] DROP CONSTRAINT CK_ConstraintName

OBJECT_ID can also be used with other "constraints" such as Foreign Key constraints or Primary Key constraints, etc. For best results, always include the appropriate object type as the second parameter for the OBJECT_ID function:

Constraint Object Types:

  • C = CHECK constraint
  • D = DEFAULT (constraint or stand-alone)
  • F = FOREIGN KEY constraint
  • PK = PRIMARY KEY constraint
  • R = Rule (old-style, stand-alone)
  • UQ = UNIQUE constraint

Also note that the schema is often required. The schema of constraints generally takes the schema of the parent table.

Failure to put your constraints (or whatever you are checking) in brackets when using this method may also cause a false negative -- if your object uses unusual characters (such as a .), the brackets are required.

๐ŸŒ
SQL Shack
sqlshack.com โ€บ how-to-use-sql-check-constraints
How to use SQL Check Constraints
October 15, 2021 - The main advantage of check constraints is that they ensure that all data in a column contains validated values โ€‹โ€‹according to the check constraint rule. For example, we define a population column for the CountryList table and we want it to hold only positive data. As we can see the CHECK (CountryPopulation > 0) expression is involved in the table creation query. This expression specifies a SQL check constraint and checks whether the data inserted into the CountryPopulation table is greater than 0.
๐ŸŒ
SQL Server Tutorial
sqlservertutorial.net โ€บ home โ€บ sql server basics โ€บ sql server check constraint
A Comprehensive Guide to SQL Server CHECK Constraint By Examples
April 11, 2020 - As you can see, the CHECK constraint definition comes after the data type. It consists of the keyword CHECK followed by a logical expression in parentheses: CHECK(unit_price > 0) Code language: SQL (Structured Query Language) (sql)
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_constraints.asp
SQL Constraints
... FOREIGN KEY - Establishes a link between data in two tables, and prevents action that will destroy the link between them ยท CHECK - Ensures that the values in a column satisfies a specific condition
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ db2-for-zos โ€บ 12.0.0
Db2 12 - Check constraints
A check constraint is a rule that specifies the values that are allowed in one or more columns of every row of a base table. For example, you can define a check constraint to ensure that all values in a column that contains ages are positive numbers.
๐ŸŒ
MySQL
dev.mysql.com โ€บ blog-archive โ€บ mysql-8-0-16-introducing-check-constraint
MySQL :: MySQL 8.0.16 Introducing CHECK constraint
April 26, 2019 - The CHECK constraint is a type of integrity constraint in SQL. The CHECK constraint specifies a search condition to check the value being entered into a row.