Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

DBMS → Introduction to DBMS 26

IDENTITY/AUTO_INCREMENT column value
Is automatically generated as next sequential integer
click to copy
Which SQL returns only the top 5 highest paid employees
SELECT * FROM emp ORDER BY salary DESC LIMIT 5
click to copy
Which SQL data type is best for storing money/currency values
DECIMAL(15,2)
click to copy
VARCHAR vs CHAR: VARCHAR stores
Variable-length strings using only needed space
click to copy
TEXT vs VARCHAR: TEXT stores
Large text (up to 65,535 chars) without specifying max length
click to copy
DATETIME vs TIMESTAMP in MySQL
TIMESTAMP converts to UTC; DATETIME stores as-is
click to copy
Which SQL command creates a backup of table structure only
CREATE TABLE backup LIKE source
click to copy
Index on column with 1 million rows and 2 distinct values (gender) is
Useless since selectivity is extremely low (50% match) - optimizer may skip it
click to copy
Covering index for SELECT id,name FROM emp WHERE dept='IT' should include
dept, id, name columns
click to copy
Table-valued function returns
A result set (table) usable in FROM clause
click to copy
Which constraint is validated at statement execution time by default
NOT DEFERRABLE (default)
click to copy
DEFERRABLE INITIALLY DEFERRED constraint
Is checked at end of transaction (COMMIT time) by default
click to copy
Which SQL creates a partial/filtered index
CREATE INDEX idx ON emp(salary) WHERE dept='IT'
click to copy
Composite index (A,B,C): which query CAN use this index
WHERE A=1 AND B=5 (leading columns)
click to copy
Index fragmentation above 30% should be addressed by
REBUILD INDEX (drops and recreates, eliminates all fragmentation)
click to copy
Which SQL checks index fragmentation in SQL Server
sys.dm_db_index_physical_stats
click to copy
UPDATE STATISTICS command purpose
Refresh the statistical metadata the optimizer uses for query planning
click to copy
Which SQL best finds all tables in current database
SHOW TABLES or SELECT * FROM information_schema.TABLES
click to copy
INFORMATION_SCHEMA is
A system database providing metadata about all database objects
click to copy
Which SQL lists all columns of the questions table
SHOW COLUMNS FROM questions OR DESCRIBE questions
click to copy
EXPLAIN SELECT * FROM questions WHERE q_level=3 shows
The execution plan: whether index is used, rows examined, join type
click to copy
Which helps identify slow queries in MySQL
EXPLAIN and slow_query_log
click to copy
Which lock type is compatible with another shared lock
Shared (S) lock
click to copy
X (exclusive) lock is compatible with
No other lock type
click to copy
Which CC protocol allows both readers and writers without blocking each other
MVCC (Multi-Version Concurrency Control)
click to copy
Optimistic CC three phases are
Read, Validate, Write (commit if valid; else restart)
click to copy

DBMS → SQL Basics 1

Which SQL creates a view that prevents DML violating its WHERE clause
CREATE VIEW v AS SELECT...WITH CHECK OPTION
click to copy

DBMS → Views 1

Updatable view conditions: a view is NOT updatable when it contains
DISTINCT, GROUP BY, aggregate functions, UNION, or joins to multiple tables
click to copy

DBMS → PL/SQL 6

BEFORE trigger can be used to
Validate or modify NEW values before they are saved to the database
click to copy
AFTER trigger is best for
Audit logging - recording what changed after the operation succeeded
click to copy
Stored procedure IN OUT parameter difference
IN: pass value to procedure. OUT: return value from procedure. INOUT: both
click to copy
Which SQL creates a stored procedure with output parameter
CREATE PROCEDURE p(OUT result INT) BEGIN...END
click to copy
Recursive stored procedure/function requires
A termination condition to prevent infinite recursion
click to copy
Which SQL creates trigger to log inserts on questions table
CREATE TRIGGER trg AFTER INSERT ON questions FOR EACH ROW INSERT INTO audit_log...
click to copy

DBMS → Transactions 3

Which isolation level is the SQL standard default in most databases
READ COMMITTED
click to copy
MySQL InnoDB default isolation level is
REPEATABLE READ
click to copy
Database transaction log is used for
Recovery: undoing incomplete transactions and redoing committed ones after crashes
click to copy

DBMS → DDL Commands 1

Which DDL command modifies column data type
ALTER TABLE t MODIFY/ALTER COLUMN col newtype
click to copy

DBMS → Relational Model 1

PRIMARY KEY vs UNIQUE: key difference
UNIQUE allows one NULL; PRIMARY KEY does not allow any NULL
click to copy

DBMS → Deadlock 1

Deadlock detection frequency tradeoff
Higher frequency: detects deadlocks sooner but adds overhead; lower: less overhead but longer wait
click to copy