Difference between revisions of "NOT NULL Column Constraint"

From Lianjapedia
Jump to: navigation, search
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Column constraint to disallow NULL values
 
Column constraint to disallow NULL values
 
  
 
==Syntax==
 
==Syntax==
 
NOT NULL
 
NOT NULL
 
  
 
==See Also==
 
==See Also==
[[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]]
+
[[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]], [[Data_Attributes#Mandatory_input|Mandatory Input]]
 
+
  
 
==Description==
 
==Description==
Line 15: Line 12:
  
 
The NOT NULL column constraint is used to specify that the column cannot contain NULL values.  The NULL column constraint can be used to allow NULL values.
 
The NOT NULL column constraint is used to specify that the column cannot contain NULL values.  The NULL column constraint can be used to allow NULL values.
 
  
 
==Example==
 
==Example==
Line 26: Line 22:
  
  
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]

Latest revision as of 12:41, 6 March 2015

Purpose

Column constraint to disallow NULL values

Syntax

NOT NULL

See Also

ALTER TABLE, CONSTRAINTS, CREATE TABLE, Mandatory Input

Description

A constraint is used to define rules that help to provide data integrity. Column constraints are specific to the column name specified. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.

The NOT NULL column constraint is used to specify that the column cannot contain NULL values. The NULL column constraint can be used to allow NULL values.

Example

ALTER TABLE customer;
  ADD COLUMN custref CHAR(5) NULL
ALTER TABLE customer;
  ALTER COLUMN custref NOT NULL