Challenge - 5 Problems
Database Master: MySQL vs PostgreSQL vs SQL Server
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Which database supports JSON data type natively?
Among MySQL, PostgreSQL, and SQL Server, which one supports JSON as a native data type allowing efficient querying and indexing?
Attempts:
2 left
💡 Hint
Think about which databases allow storing JSON documents and querying them efficiently.
✗ Incorrect
Both MySQL (from version 5.7) and PostgreSQL support JSON data types natively, allowing efficient storage and querying. SQL Server supports JSON but stores it as plain text without a native JSON type.
❓ query_result
intermediate2:00remaining
Identify the database by its default case sensitivity in string comparisons
Given the following behavior: String comparisons are case-insensitive by default in this database. Which database is it?
Attempts:
2 left
💡 Hint
Consider which database treats 'abc' and 'ABC' as equal by default in WHERE clauses.
✗ Incorrect
MySQL and SQL Server use case-insensitive collation by default for string comparisons, making them case-insensitive unless specified otherwise. PostgreSQL is case-sensitive by default.
📝 Syntax
advanced2:00remaining
Which SQL syntax is valid for limiting query results in all three databases?
You want to limit the number of rows returned by a query to 5. Which of the following SQL statements will work correctly in MySQL, PostgreSQL, and SQL Server?
SQL
SELECT * FROM employees FETCH FIRST 5 ROWS ONLY;
Attempts:
2 left
💡 Hint
Think about the SQL standard syntax supported by all three databases.
✗ Incorrect
The syntax 'FETCH FIRST 5 ROWS ONLY' is part of the SQL standard and supported by PostgreSQL, SQL Server (2012+), and MySQL (8.0+). LIMIT works in MySQL and PostgreSQL but not SQL Server. TOP is SQL Server specific. ROWNUM is Oracle specific.
❓ optimization
advanced2:00remaining
Which database supports partial indexes for query optimization?
Partial indexes allow indexing only a subset of rows in a table. Which database supports partial indexes natively?
Attempts:
2 left
💡 Hint
Think about which database allows creating indexes with a WHERE clause.
✗ Incorrect
PostgreSQL supports partial indexes, allowing indexes on a subset of rows using a WHERE clause. MySQL and SQL Server do not support partial indexes natively.
🔧 Debug
expert3:00remaining
Why does this SQL Server query fail but works in MySQL and PostgreSQL?
Consider this query:
SELECT * FROM orders WHERE order_date = '2023-02-30';
It runs (with warning) in MySQL but fails in SQL Server and PostgreSQL. Why?
Attempts:
2 left
💡 Hint
Think about how each database handles invalid date values.
✗ Incorrect
SQL Server and PostgreSQL validate date literals strictly and throw an error for invalid dates like '2023-02-30'. MySQL issues a warning but allows the query to run, converting invalid dates silently.