Specify the master password to connect to the PostgreSQL. To create a CHECK constraint, launch pgAdmin4. Now, let us insert a record with Product_Cost 10 days, the query must return an error. When we add a record with the Product_Cost 0) We want to add a CHECK constraint on the Product_Cost column of the tblPurchaseOrder table. The CHECK condition must be specified between the parentheses Condition: Specify the CHECK condition.The constraint name must be specified after ADD CONSTRAINT expression constraint_name: Specify the desired constraint name.tbl_name: Specify the table name which contains the column on which you want to add the CHECK CONSTRAINT.The syntax to add the constraint is as the following.ĪLTER TABLE tbl_name ADD CONSTRAINT constraint_name CHECK (condition) We can add a constraint by using ALTER TABLE statement. Following is the pattern:Ĭreate table tbl_name(col_1 datatype, Col_2 data_type CONSTRAINT constraint_name (Check_condition))Īdd constraint using ALTER TABLE statement We can specify the constraint name after specifying the CONSTRAINT expression.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |