Q81. Valid constraints in MySQL?
MySQL supports a complete set of integrity constraints: 1. **`PRIMARY KEY`**: Uniquely identifies each row (implies `NOT NULL` and `UNIQUE`). 2. **`FOREIGN KEY`**: Enforc...
Technical Question Bank · Peer-Reviewed
Search and filter frequently asked interview questions across technical, programming, and behavioral domains. Tailor your interview preparation by difficulty for freshers or experienced developers (115 available).
MySQL supports a complete set of integrity constraints: 1. **`PRIMARY KEY`**: Uniquely identifies each row (implies `NOT NULL` and `UNIQUE`). 2. **`FOREIGN KEY`**: Enforc...
Any assertion claiming that **constraints are optional in production** or that **constraints significantly slow down reads** is false. ### Why Constraints Are Vital: - Co...
The **`NOT NULL`** constraint enforces that a column must always contain a valid data value and cannot accept `NULL`: ```sql CREATE TABLE employees ( id INT PRIMARY KEY, ...
To enforce that every value in a non-primary key column is unique, apply the **`UNIQUE`** constraint: ```sql CREATE TABLE users ( id INT PRIMARY KEY, email VARCHAR(255) U...
A **`CHECK`** constraint ensures that all values stored in a column satisfy a specific boolean condition: ```sql CREATE TABLE products ( product_id INT PRIMARY KEY, name ...
| PRIMARY KEY | UNIQUE | |-------------|--------| | One per table | Multiple per table | | Cannot be NULL | Usually allows one NULL | | Implicitly indexed | Explicitly in...
Permanently removes the table definition, all data, indexes, triggers, and constraints. **Cannot be undone** (unless in a transaction that rolls back, in some DBs). ```sq...
While both `DROP` and `TRUNCATE` are DDL operations, their scope is fundamentally different: | Feature | `TRUNCATE TABLE` | `DROP TABLE` | | :--- | :--- | :--- | | **Data...
To add an `order_date` column to an existing table, use `ALTER TABLE ... ADD COLUMN`: ```sql ALTER TABLE `orders` ADD COLUMN order_date DATE NOT NULL DEFAULT (CURRENT_DAT...
```sql -- MySQL ALTER TABLE Customer CHANGE Address Addr VARCHAR(50); -- PostgreSQL / Standard ALTER TABLE Customer RENAME COLUMN Address TO Addr; ```
HireXTech uses essential storage to remember your study preferences and third-party advertising cookies via Google AdSense in compliance with GDPR. You can choose to enable essential cookies only or accept all cookies. Read our Privacy Policy.