SQL MCQs | Database Interview MCQ Questions and Answers

Test your knowledge of Database - [ SQL ] section with these interactive multiple-choice questions.

« First 6 7 8 9 Last »
« Previous Page Next Page »

121. Which analytical function calculates running totals?

  • a) SUM() OVER()
  • b) RUNNING_TOTAL()
  • c) CUMULATE()
  • d) AGGREGATE()
Answer: A - SUM(column) OVER(ORDER BY sort_column) computes cumulative sums.

122. What is the purpose of database auditing?

  • a) Tracks data access and changes
  • b) Optimizes performance
  • c) Compresses backups
  • d) Validates schemas
Answer: A - Auditing maintains security logs for compliance (e.g., AUDIT SELECT ON table).

123. Which SQL feature implements blockchain-like tables?

  • a) Immutable ledger tables
  • b) Blockchain extensions
  • c) Hash-chain constraints
  • d) CryptoTables
Answer: A - Oracle 21c+ and SQL Server 2022+ offer tamper-evident ledger tables.

124. What is a time travel query?

  • a) Retrieves historical data at past points
  • b) Measures query duration
  • c) Replays transactions
  • d) Synchronizes clocks
Answer: A - Snowflake and Oracle Flashback Query enable historical snapshots.

125. Which graph database function finds shortest paths?

  • a) SHORTEST_PATH()
  • b) FIND_ROUTE()
  • c) TRAVERSE()
  • d) CONNECT_BY()
Answer: A - Graph extensions in Oracle/PG use SHORTEST_PATH syntax.

126. What is the purpose of the SQL PERCENTILE_CONT() function?

  • a) Computes continuous percentiles
  • b) Counts distinct values
  • c) Groups by percentage
  • d) Samples data
Answer: A - Calculates interpolated values at specified percentiles (e.g., median).

127. Which statement enables change tracking?

  • a) ALTER DATABASE ENABLE CHANGE_TRACKING
  • b) START TRACKING CHANGES
  • c) CREATE CHANGE_LOG
  • d) ENABLE VERSIONING
Answer: A - Tracks DML changes for sync applications (SQL Server feature).

128. What is the purpose of the SQL FIRST_VALUE() function?

  • a) Returns first value in window frame
  • b) Finds initial table row
  • c) Gets oldest record
  • d) Retrieves creation timestamp
Answer: A - Window function that accesses the first row in a partition.

129. Which feature automatically classifies sensitive data?

  • a) Data Discovery & Classification
  • b) Smart Tags
  • c) Sensitivity Labels
  • d) Auto-Categorization
Answer: A - SQL Server and Azure SQL can detect PII/PCI data patterns.

130. What is the purpose of the SQL GENERATE_SERIES() function?

  • a) Creates number/date sequences
  • b) Generates test data
  • c) Outputs result sets
  • d) Replicates rows
Answer: A - PostgreSQL/SQL Server 2022+ function for sequence generation.

131. Which statement creates a temporal table?

  • a) CREATE TABLE...WITH SYSTEM_VERSIONING
  • b) MAKE TEMPORAL TABLE
  • c) CREATE HISTORY TABLE
  • d) DEFINE VERSIONED TABLE
Answer: A - Automatically maintains historical versions of rows.

132. What is the purpose of the SQL LISTAGG() function?

  • a) Concatenates string values
  • b) Lists table columns
  • c) Aggregates arrays
  • d) Generates XML
Answer: A - Oracle's string aggregation function (similar to STRING_AGG).

133. Which database supports time-series extensions?

  • a) TimescaleDB
  • b) InfluxDB
  • c) Prometheus
  • d) All of the above
Answer: D - Specialized databases for timestamped data analysis.

134. What is the purpose of the SQL CUME_DIST() function?

  • a) Calculates cumulative distribution
  • b) Measures distance
  • c) Computes averages
  • d) Counts distincts
Answer: A - Returns relative position (0-1) of a value within a window.

135. Which statement creates a columnstore index?

  • a) CREATE COLUMNSTORE INDEX
  • b) MAKE COLUMN INDEX
  • c) ADD COLUMNSTORE
  • d) DEFINE COLUMNAR INDEX
Answer: A - Optimized for analytics workloads (SQL Server feature).

136. What is the purpose of the SQL APPROX_PERCENTILE() function?

  • a) Estimates percentiles with reduced accuracy
  • b) Calculates exact percentiles
  • c) Samples random data
  • d) Groups by percentage
Answer: A - Uses approximation algorithms for big data efficiency.

137. Which feature enables zero-downtime migrations?

  • a) Database mirroring
  • b) Log shipping
  • c) Always On Availability Groups
  • d) All of the above
Answer: D - High-availability technologies minimize downtime during upgrades.

138. What is the purpose of the SQL WIDTH_BUCKET() function?

  • a) Assigns values to equi-width histogram bins
  • b) Measures column sizes
  • c) Calculates storage requirements
  • d) Partitions tables
Answer: A - Useful for data distribution analysis (Oracle/PostgreSQL).

139. Which database provides built-in graph algorithms?

  • a) Neo4j
  • b) Oracle PGX
  • c) SQL Server Graph
  • d) All of the above
Answer: D - Offer pathfinding, centrality, and community detection.

140. What is the purpose of the SQL BIT_AND() function?

  • a) Performs bitwise AND across rows
  • b) Combines binary data
  • c) Encrypts values
  • d) Compresses bitmaps
Answer: A - Aggregate function for bitmask operations (MySQL/PostgreSQL).
« First 6 7 8 9 Last »
« Previous Page Next Page »

SQL MCQs - Master Database Concepts from Basic to Advanced | PCBooks

🚀 Want to master SQL for interviews and exams? PCBooks offers the most comprehensive free SQL MCQ bank covering queries, joins, subqueries, and database optimization. Perfect for:

📊 SQL Query & Database Design MCQs

👉 SELECT, INSERT, UPDATE, DELETE command practice
👉 INNER, LEFT, RIGHT, FULL JOINs with real-world scenarios
👉 GROUP BY, HAVING, ORDER BY advanced usage
👉 Indexing strategies and query optimization techniques

📚 Free SQL Learning Path

🎯 Step-by-step tutorials on:
- Database normalization (1NF to BCNF)
- Stored procedures and functions
- Window functions (ROW_NUMBER, RANK, DENSE_RANK)
- Transaction control (COMMIT, ROLLBACK, SAVEPOINT)
🎯 Chapter-wise quizzes with detailed explanations
🎯 Downloadable SQL cheat sheets for quick revision

🚀 Practice SQL MCQs Now

Start Basic SQL MCQs →
MongoDB MCQs Practice →
Top 300 DBMS Concepts Interview Questions →


🏆 Trusted by 75,000+ learners for SQL certification and career growth!