Back to search

The University of Western Ontario

DO LLMS REALLY UNDERSTAND SQL?

Abstract

dc:description.abstract

The rise of large language models (LLMs) has significantly influenced various fields, including natural language processing (NLP) and image generation, by making complex computational tasks more accessible. Despite their remarkable generative capabilities, a fundamental ques- tion remains regarding their level of understanding, particularly in structured domains such as SQL, where precise logic and syntactic accuracy are essential. This work evaluates the extent to which LLMs comprehend SQL by assessing their performance on key tasks, includ- ing syntax error detection, missing token identification, query performance prediction, query equivalence checking, and query explanation. These tasks collectively examine the models’ ability to recognize patterns, maintain context awareness, interpret semantics, and ensure logical coherence—capabilities that are critical for genuine SQL understanding. To enable a rigorous evaluation, we construct labeled datasets from well-established SQL workloads and conduct extensive experiments on state-of-the-art LLMs. Our analysis specif- ically investigates how query complexity and distinct syntactic features impact model perfor- mance. The results indicate that while models such as GPT4 excel in tasks that rely on pattern recognition and contextual awareness, they exhibit persistent difficulties in deeper semantic understanding and logical consistency. These challenges are particularly evident in tasks such as accurately predicting query performance and verifying query equivalence. This gap suggests that current LLMs, despite their syntactic and structural proficiency, lack the ability to integrate deeper semantic reasoning required for comprehensive SQL comprehension. Our findings underscore the need for future advancements in LLMs to focus on im- proving their reasoning abilities and their capacity to incorporate domain-specific knowledge. Enhancing these aspects would enable a transition from syntactic fluency to a more logic- driven understanding, thereby unlocking the full potential of SQL in various computational applications.

Degree

thesis:*
Name thesis:degree_name
M Sc
Discipline thesis:degree_discipline
Computer Science
Grantor dc:publisher
The University of Western Ontario
Year dc:date.issued
2025

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Rahaman, Ananya
Advisor dc:contributor.advisor
  • Mostafa Milani

Subjects

dc:subject × 3

Rights

Language dc:language.iso
en_ca

Identifiers

dc:identifier.*

Chain of custody

source
Harvested from
Western University
Base URL
uwo.scholaris.ca/server/oai/request
Last updated
2026-11-26
Source record
OAI-PMH GetRecord
related terms
citation

Rahaman, Ananya. DO LLMS REALLY UNDERSTAND SQL?. The University of Western Ontario, 2025. https://hdl.handle.net/20.500.14721/31571