Q1
True / FalseIn MySQL, the AUTO_INCREMENT attribute can be applied to any column.
The AUTO_INCREMENT attribute can only be applied to columns defined as PRIMARY KEY or UNIQUE in MySQL.
Q2
True / FalseIn MySQL, only one column per table can be assigned the AUTO_INCREMENT attribute.
MySQL allows only one column per table to be assigned the AUTO_INCREMENT attribute.
Q3
True / FalseThe AUTO_INCREMENT value in MySQL starts at 1 by default.
By default, MySQL starts the AUTO_INCREMENT value at 1 and increments it by 1 for each new row.
Q4
True / FalseIn MySQL, you can set the initial value for an AUTO_INCREMENT column using the AUTO_INCREMENT table option.
You can set the initial value for an AUTO_INCREMENT column by using the AUTO_INCREMENT table option in the CREATE TABLE or ALTER TABLE statement.
Q5
True / FalseThe AUTO_INCREMENT attribute in MySQL can be used with VARCHAR data type columns.
The AUTO_INCREMENT attribute can only be used with numeric data types such as INT, TINYINT, SMALLINT, MEDIUMINT, BIGINT.
Q6
True / FalseIn MySQL, deleting the highest-numbered row in an AUTO_INCREMENT column and then inserting a new row will reuse the deleted number.
By default, MySQL will not reuse the deleted number. It will continue to increment the AUTO_INCREMENT value.
Q7
True / FalseMySQL’s AUTO_INCREMENT attribute can be used in conjunction with the PARTITION feature.
MySQL’s AUTO_INCREMENT attribute can be used with tables that are partitioned, and each partition will maintain its own AUTO_INCREMENT sequence.
Q8
True / FalseIn MySQL, if the AUTO_INCREMENT column reaches its maximum value, it will automatically reset to 1.
If the AUTO_INCREMENT column reaches its maximum value, MySQL will generate an error, and you need to handle it manually. It will not reset to 1 automatically.
Q9
True / FalseIn MySQL, you can reset the AUTO_INCREMENT value of a table without deleting any rows.
You can reset the AUTO_INCREMENT value by using the ALTER TABLE statement to set a new AUTO_INCREMENT value.
Q10
True / FalseIn MySQL, using INSERT IGNORE with an AUTO_INCREMENT column will skip rows that would cause a duplicate key error and continue to increment the AUTO_INCREMENT value.
The INSERT IGNORE statement in MySQL will skip rows that would cause a duplicate key error and will continue to increment the AUTO_INCREMENT value without interruption.
Q24
Multiple ChoiceWhich SQL statement correctly uses AUTO_INCREMENT for a non-primary key column?
SQL Code
CREATE TABLE inventory (
item_id INT PRIMARY KEY,
serial_number INT AUTO_INCREMENT,
product_name VARCHAR(100)
);
While AUTO_INCREMENT is commonly used for primary keys, it can also be applied to a non-primary key column to ensure unique sequential values.
Q25
Multiple ChoiceSelect the correct SQL statement to ensure that an AUTO_INCREMENT column starts at 1 by default.
SQL Code
CREATE TABLE accounts (
account_id INT AUTO_INCREMENT PRIMARY KEY,
balance DECIMAL(10, 2)
);
By default, the AUTO_INCREMENT column starts at 1 unless explicitly defined otherwise, ensuring each new row gets a unique sequential integer.
Q26
Multiple ChoiceDetermine the correct SQL statement to enforce an AUTO_INCREMENT constraint on a new table while setting the initial value.
SQL Code
CREATE TABLE memberships (
membership_id INT AUTO_INCREMENT PRIMARY KEY,
start_date DATE,
AUTO_INCREMENT = 500
);
In this scenario, the AUTO_INCREMENT value is set to start at 500, meaning the first row inserted will have a membership_id of 500.