MYSQL DATABASE INTERVIEW QUESTIONS

Course:MySQL
Chapter:Chapter 5 - DDL (Data Definition Language)
Questions Count:10
1

What is a UNIQUE constraint in MySQL?

Explanation:
2

How do you add a UNIQUE constraint to a column when creating a table?

Explanation:
3

Can a table have multiple UNIQUE constraints?

Explanation:
4

How can you add a UNIQUE constraint to an existing table?

Explanation:
5

What happens if you try to insert duplicate values into a column with a UNIQUE constraint?

Explanation:
6

Can a UNIQUE constraint be applied to multiple columns together? Explain with an example.

Explanation:
7

In this case, the combination of ProductID and CustomerID must be unique, meaning that no two rows can have the same pair of ProductID and CustomerID values.

Explanation:
8

How can you drop a UNIQUE constraint from a table?

Explanation:
9

What are the differences between a UNIQUE constraint and a PRIMARY KEY in MySQL?

Explanation:
10

Given the table definition below, identify the error in the UNIQUE constraint implementation and correct it.CREATE TABLE Students ( StudentID INT, FirstName VARCHAR(100), LastName VARCHAR(100), UNIQUE (FirstName, LastName), UNIQUE (StudentID) );

Explanation: