how to check the constraints on a table in sql code example

Example 1: check constraint in sql

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    City varchar(255),
    CONSTRAINT CHK_Person CHECK (Age>=18 AND City='Sandnes')
);

Example 2: what are the constraints in sql

NOT NULL 	 # Ensures a column cannot have a NULL value
UNIQUE 		 # Ensures all values in a column are unique
PRIMARY KEY  # Identifies a record in a table, is NOT NULL & UNIQUE
FOREIGN KEY  # References a unique record from another table
CHECK		 # Ensures all column values satisfy a condition
DEFAULT		 # Set a default value for a column if none is entered
INDEX		 # Quick way of retrieving records from database

Example 3: check constraint in sql

#For one column
CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int CHECK (Age>=18)
);