SQL Test in Delphi - Possible Questions
This document provides an overview of possible SQL-related questions that can be asked in a
Delphi context, including beginner, intermediate, and advanced (hard) level questions.
1. Basic SQL Questions
1.1 What is SQL and how is it used in Delphi?
1.2 Write a basic SQL SELECT query to retrieve all rows from a table called Customers.
1.3 How do you connect a Delphi application to a database using FireDAC or ADO?
1.4 How do you use parameters in a SQL query in Delphi?
1.5 What is the purpose of the WHERE clause in SQL?
1.6 Write a query to select all customers from the Customers table where the city is 'Pretoria'.
1.7 How do you use the ORDER BY clause in a SELECT statement?
1.8 Explain the purpose of the LIKE operator in SQL and give an example.
2. Intermediate SQL and Delphi Integration Questions
2.1 How do you execute an INSERT SQL statement from Delphi?
2.2 Write a SQL query to update the email of a customer with CustomerID = 5.
2.3 Explain how SQL injection works and how to prevent it in Delphi.
2.4 Describe the difference between INNER JOIN and LEFT JOIN.
2.5 Write a query that joins the Orders and Customers tables using CustomerID.
2.6 How do you use SQL transactions in Delphi?
2.7 What is the purpose of a primary key in a database table?
2.8 How can you use TFDQuery or TADOQuery to show SQL results in a DBGrid?
3. Advanced / Hard Questions
3.1 Write a query to count the number of orders per customer and display only those with more than
3 orders.
3.2 How do you use stored procedures in Delphi, and how do you pass parameters to them?
3.3 Write a SQL query to find duplicate email addresses in the Customers table.
3.4 How do you handle database errors (like constraint violations) in Delphi?
3.5 What are the differences between FireDAC and ADO for database access in Delphi?
3.6 Write a Delphi function that runs a parameterized SELECT query and returns the result as a
string.
3.7 Describe how you would optimize a slow-performing SQL query in a Delphi application.
3.8 How would you implement role-based access control (RBAC) in a SQL database used by
Delphi?