java2db

Sql NOT NULL constraint on table column



The use of  NOT NULL constraint is to restrict null values.By default the column allows the null values.We can specify  it in the column level but not in the table or view level.When a column is defined as NOT NULL, then that column becomes mandatory column.It implies that a value must be entered to the column.

A null values is different from a blank or a zero. We can say that null means undefined.

 
NOT NULL constraint   Cannot specify NULL or NOT NULL for a view.

NOT NULL constraint   Cannot specify NULL or NOT NULL for an attribute of an object. Instead , use a CHECK constraint

……with the IS [NOT] NULL condition.

 

NOT NULL constraint NOT NULL constraint at column level :

Specify the constraint with the column declaration .

We cannot apply  NOT NULL  constraint at the table or view level.

 

NOT NULL constraint NOT NULL with ALTER:

If the table already exists , use ALTER TABLE  to apply NULL or NOT NULL constraint for the columns.

 

NOT NULL constraint Drop NOT NULL constraint :

Drop the NULL or NOT NULL constraint with it’s name.




Related Posts :
Sql FOREIGN KEY constraint on table column
Sql CHECK constraint on table column
Sql UNIQUE constraint on table column
Sql PRIMARY KEY constraint on table column
Sql full outer join on tables with an example
Sql right outer join on tables with an example
Sql left outer join on tables with an example
Sql inner join on tables with an example
   [will not be published]



^ <