Which of the following is the correct way of defining a DEFAULT constraint for a table?
-
CREATE TABLE STUDENTS( STUDENT_ID INT NOT NULL, STUDENT_NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25) , MARKS INT DEFAULT 35,
PRIMARY KEY (STUDENT_ID) ); -
CREATE TABLE STUDENTS( STUDENT_ID INT NOT NULL, STUDENT_NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25) , PRIMARY KEY (STUDENT_ID) ); ALTER TABLE STUDENTS ADD MARKS INT DEFAULT 35;
-
Both option 1 and option 2 are correct.
-
DEFAULT is not a valid constraint in ORACLE.
-
DEFAULT constraint was discontinued from ORACLE 9i onwards.
Yes, both option 1 and option 2 are correct.
Option 1 is the example for defining a DEFAULT constraint using CREATE statement.
Option 2 is the example for defining a DEFAULT constraint using an ALTER statement after the table is created using CREATE.