Multiple choice

Which of the following is the correct way of defining a DEFAULT constraint for a table?

  1. 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) );

  2. 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;

  3. Both option 1 and option 2 are correct.

  4. DEFAULT is not a valid constraint in ORACLE.

  5. DEFAULT constraint was discontinued from ORACLE 9i onwards.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

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.