Q1
True / FalseThe DEFAULT constraint in MySQL automatically assigns a default value to a column if no value is provided during insertion.
The DEFAULT constraint in MySQL is used to provide a default value for a column if no value is specified when a row is inserted.
Q2
True / FalseIn MySQL, the DEFAULT constraint can only be applied to numeric columns.
The DEFAULT constraint in MySQL can be applied to any data type, including numeric, string, and date types.
Q3
True / FalseIn MySQL, you can add a DEFAULT constraint to an existing column using the ALTER TABLE statement.
You can use the ALTER TABLE statement in MySQL to add a DEFAULT constraint to an existing column.
Q4
True / FalseIn MySQL, the DEFAULT constraint can be used with the TIMESTAMP data type to automatically set the current date and time for new rows.
In MySQL, you can set a TIMESTAMP column to have a default value of CURRENT_TIMESTAMP to automatically insert the current date and time for new rows.
Q5
True / FalseMySQL allows the DEFAULT constraint to be used with the AUTO_INCREMENT attribute.
The AUTO_INCREMENT attribute in MySQL automatically generates a unique value for the column, so the DEFAULT constraint cannot be used with it.
Q6
True / FalseIf a column in MySQL has a DEFAULT constraint and a NULL value is inserted, the default value will be used instead of NULL.
If NULL is explicitly inserted into a column with a DEFAULT constraint, NULL will be stored. The default value is only used when no value is provided.
Q7
True / FalseIn MySQL, you can define a DEFAULT constraint that is a result of an arithmetic operation.
You can define a DEFAULT constraint in MySQL that involves simple arithmetic operations, such as DEFAULT (5 + 3).
Q8
True / FalseIn MySQL, a DEFAULT constraint can reference other columns in the same table.
The DEFAULT constraint in MySQL cannot reference other columns in the table; it can only be a constant value or a function that returns a constant value.
Q9
True / FalseIn MySQL, you can set the default value of a column to be an expression involving system functions like UUID().
You can use certain functions like UUID() as default values in MySQL, which will generate a unique identifier for each new row.
Q10
True / FalseWhen exporting a MySQL database, the DEFAULT constraints on the columns are not included in the dump file.
When exporting a MySQL database, the DEFAULT constraints on the columns are included in the dump file. This ensures that the database schema, including default values, is preserved during import.
Q26
Multiple ChoiceIdentify the correct SQL statement to create a table with multiple columns, each having a different default value.
SQL Code
CREATE TABLE accounts (
account_id INT PRIMARY KEY,
account_type VARCHAR(20) DEFAULT 'Checking',
balance DECIMAL(10, 2) DEFAULT 0.00
);
Each column in the table is assigned a specific default value, which will be used if no other value is provided during insertion.
Q28
Multiple ChoiceWhich SQL statement correctly uses the DEFAULT constraint with an ENUM data type?
SQL Code
CREATE TABLE orders (
order_id INT PRIMARY KEY,
order_status ENUM('Pending', 'Completed', 'Canceled') DEFAULT 'Pending'
);
The DEFAULT constraint can be used with an ENUM data type to specify a default option from the list of allowed values.