RSS Feed

NOT NULL Constraint

SQL NOT NULL Constraint

By default all columns accept NULL values. SQL NOT NULL Constraint indicates that the column will not accept NULL values. NOT NULL Constraint can only be used as a column Constraint. It is not supported for table or domain constraints.

Example of SQL NOT NULL Constraint

The price of the beer cannot be NULL in the below Create Table query:

CREATE TABLE Sells (
  bar   CHAR(20),
  beer  VARCHAR(20) DEFAULT 'Kingfisher',
  price REAL  NOT NULL,
  PRIMARY KEY (bar,beer)
 );

No comments:

Post a Comment