×
☰ See All Chapters

Oracle DEFAULT constraint

The ANSI/ISO standard allows defining default values that columns should have. Usually, if no value is supplied for a column, then it is assigned a NULL value. The DEFAULT modifier overrides this.

Oracle DEFAULT constraint example

In the below example if no value supplied for column SUB_NAME then default value ‘Hello’ is inserted.

CREATE TABLE SUBJECTS

(

SUB_NO INTEGER NOT NULL,

SUB_NAME CHAR(20) DEFAULT 'Hello',

CREDITS NUMBER(2) CHECK (CREDITS > 0 AND CREDITS <= 10),

SUB_CODE NUMBER (2) DEFAULT 65

);

 

 


All Chapters
Author