Govt. Exams
Entrance Exams
3NF (Third Normal Form) eliminates update, insertion, and deletion anomalies by removing transitive dependencies.
COALESCE returns first non-NULL value. It skips two NULLs and returns 'SQL' as first non-NULL argument.
B-Tree indexes are optimal for range queries (BETWEEN, <, >). Hash indexes are for equality, Full-Text for text search, Spatial for geographic data.
Correct syntax uses AS keyword with alias without quotes (unless alias has spaces). Option A uses unnecessary quotes, B omits AS.
CROSS JOIN produces all combinations of rows (m×n rows if m and n are table sizes). INNER JOIN filters based on condition.
Aggregate functions cannot be used directly in WHERE clause. Must use subquery in parentheses to calculate average first.
SUM() and AVG() ignore NULL values. COUNT(*) counts all rows including those with NULLs, while COUNT(column) ignores NULLs.
# SQL Statement for Deleting Records While Preserving Table Structure
Understanding the differences between SQL commands for removing data versus removing entire tables is essential for database management.
## Step 1: Identify the Requirement
The question asks for a command that removes ALL records from a table but keeps the table structure (columns, constraints, indexes) intact.
## Step 2: Analyze Each Option
| Option | Command | Effect | Table Structure |
|--------|---------|--------|-----------------|
| (A) | DELETE FROM | Removes rows one by one (slower) | ✓ Preserved |
| (B) | DROP TABLE | Removes entire table including structure | ✗ Deleted |
| (C) | TRUNCATE TABLE | Removes all rows at once (faster) | ✓ Preserved |
| (D) | REMOVE FROM | Not a valid SQL command | N/A |
## Step 3: Why TRUNCATE is Superior
TRUNCATE TABLE uses minimal transaction log space, resets identity seeds, and is faster than DELETE because it deallocates data pages rather than removing rows individually.
The correct answer is (C) TRUNCATE TABLE table_name; — it removes all records while preserving the table structure, indexes, and constraints.
The underscore (_) wildcard matches exactly one character, while % matches zero or more characters.
PRIMARY KEY ensures uniqueness and prevents NULL values in a column, uniquely identifying each row in a table.