hemant kumar
What is NOT NULL Constraint?
2 Answer(s)      4 years and 6 months ago
Posted in : SQL

What is NOT NULL Constraint?

Advertisement
View Answers

November 19, 2010 at 12:56 PM


Hi,

The NOT NULL constraint enforces a column to NOT accept NULL values.The NOT NULL constraint enforces a 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.

for example-

CREATE TABLE items (
   item_num INTEGER,
   manufcode CHAR(3) NOT NULL,
   promotype INTEGER,
   descrip CHAR(20))

Thanks,



November 19, 2010 at 3:28 PM


hi,

the Not Null constraint can be declared to a column in which you are not supposed to enter a null vale i.e you can't leave it as blank. If you had declare an column with not null then you must enter a value.

Create table stud( sid number not null, sname varchar2(20) not null, pno number);

While inserting values

101 praveen ;//accepted rajesh 1234568;//not accepted throws an error 101 123456;//not accepted throws an error