Consider the following SQL statement: sql CREATE TABLE Employees ( ID INT…
2025
Consider the following SQL statement:
sql
CREATE TABLE Employees (
ID INT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
HireDate DATE DEFAULT CURRENT_DATE
);
What does the DEFAULT keyword accomplish here?
- A.
Automatically updates HireDate when the row is modified
- B.
Sets HireDate to the current date if no value is provided during insertion
- C.
Prevents manual entry of HireDate
- D.
Ensures HireDate is always unique
Attempted by 124 students.
Show answer & explanation
Correct answer: B
In SQL, the DEFAULT keyword assigns a predefined value to a column when no value is supplied during insertion. In this statement:
HireDate DATE DEFAULT CURRENT_DATE
If a new employee record is inserted without specifying HireDate, the database automatically stores the current date in that column.