Database Questions in Interviews

Last updated: December 3, 2026

This article applies to the new Interview experience.

Database questions in HackerRank Interviews provide a shared query editor where you and the candidate can write and run SQL queries. Use these questions to evaluate SQL, schema, and data modeling skills. You can select a database, run queries against the tables described in the question, and compare the result with the expected output.

To add a Database question to your interview, see 📄 Manage Questions in an Interview → Adding a Data Science, Database, or DevOps question.

Database question components

A Database question contains a collapsible question panel on the left, the query editor in the center, and the Output panel below the editor.

For information on other interview controls, see 📄 Navigate the Interview Interface and Controls.

Question panel

The Question panel displays the question title, the problem statement, and the table schema. Depending on the question, it can also include sample input, sample output, and an explanation of the expected result.

Click the Toggle left panel icon in the upper-left corner of the query editor to hide or show the question panel.

Note:

Query editor

Use the query editor in the center to write and edit SQL queries. The editor displays line numbers and highlights SQL syntax. Changes that you or the candidate make in the editor appear for both of you in real time. Questions can load starter code in the editor, such as a comment that reminds you to end the query with a semicolon.

Select a database

Click the database dropdown in the upper-right corner of the query editor, and select a database. The dropdown lists the databases that the question supports, which can include the following:

  • DB2

  • MS SQL Server

  • MySQL

  • Oracle (PL/SQL enabled)

  • PostgreSQL

Note: When you or the candidate select a database, it changes for both of you. The editor keeps a separate query for each database. When you switch to another database, the editor displays the query for that database. When you switch back, your earlier query is restored.

Run a query

Click the Run Query icon in the upper-right corner to run the query. The candidate can also run the query. The result appears in the Output panel for both you and the candidate.

Output panel

Click Output at the bottom of the query editor, or click the arrow on the right side of the panel, to expand or collapse it. Until you run a query, the panel displays a message that asks you to run the query.

After you run a query, the panel displays whether the query is correct or incorrect, followed by these sections:

  • Run status: Shows the error message when the query fails to run, for example, because of a syntax error.

  • Output: Shows the result that the query returns. To download the output, click the Download output icon next to Output.

  • Expected output: Shows the result that the question expects. By default, only interviewers can see this section.

Editor settings

To change the query editor settings, click the Settings icon in the upper-right corner and select the Editor tab. You can change the following settings:

  • Font Size: Select a font size from 12 to 16.

  • Tab Size: Select 2 spaces, 4 spaces, or 8 spaces.

  • Mode: Select Normal or Vim.

Note: For information about the Interview and Audio & Video tabs in Settings, see 📄 Navigate the Interview Interface and Controls → Configure interview settings.