The NOT NULL constraint forces a column to NOT accept NULL values.
The NOT NULL constraint field to always contain a value. This means that you cannot insert
a new record, or update a record without adding a value to this field.
A primary key column cannot contain NULL values.
The NOT NULL constraint field to always contain a value. This means that you cannot insert
a new record, or update a record without adding a value to this field.
A primary key column cannot contain NULL values.
CREATE TABLE CANDIDATE
(
CandidateId int IDENTITY(1,1) PRIMARY KEY,
CandidateNumber int NOT NULL UNIQUE,
LastName varchar(50) NOT NULL,
FirstName varchar(50) NOT NULL,
PostCode int NULL,
Address varchar(50) NULL,
Phone varchar(50) NULL,
)
(
CandidateId int IDENTITY(1,1) PRIMARY KEY,
CandidateNumber int NOT NULL UNIQUE,
LastName varchar(50) NOT NULL,
FirstName varchar(50) NOT NULL,
PostCode int NULL,
Address varchar(50) NULL,
Phone varchar(50) NULL,
)
We see that "CandidateNumber","FirstName"," LastName" is set to "NOT NULL" this means these columns neeeds to contain data. while "PostCode","Address" and "Phone" may be left empty, they do not need to filled out.
Set NOT NULL int the MS-SQL Server Tools:
In the Designer table you can easily set which columns that should allow NULL or NOT NULL
Post a Comment