<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp" -->

---
title: AI Hallucinated a Table That Was Never There | daily.dev
description: A cartoon-style vignette introduces Cardinal, a fictional AI assistant that writes fluent but fabricated SQL queries against tables that don't exist in the...
canonical: https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: AI Hallucinated a Table That Was Never There | daily.dev
og:description: A cartoon-style vignette introduces Cardinal, a fictional AI assistant that writes fluent but fabricated SQL queries against tables that don't exist in the...
og:url: https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp
og:image: https://api.daily.dev/og/posts/z4OUCB6LP.png
og:image:alt: AI Hallucinated a Table That Was Never There
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Hallucinated a Table That Was Never There

**[SQL Authority](https://daily.dev/sources/sql-authority)** · 2 min read · 87 upvotes · 10 comments

## Summary

A cartoon-style vignette introduces Cardinal, a fictional AI assistant that writes fluent but fabricated SQL queries against tables that don't exist in the actual database. The piece explains why AI hallucinates schema objects (it pattern-matches on plausible names rather than checking the real database) and offers a simple mitigation: paste the actual schema into the prompt before asking a question, and instruct the model not to invent tables or columns. It frames this as the most common and least visible AI mistake in database work, since the resulting error looks like an ordinary SQL error rather than an AI failure.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.sqlauthority.com/2026/09/26/ai-hallucinated-a-table>

## Questions this post answers

### why does an AI assistant write SQL queries against tables that don't exist in my database

An AI model generates SQL based on patterns learned from vast amounts of training data, not from actual knowledge of a specific database. When a query needs a table the schema doesn't have, the model invents a plausible-sounding name, like Revenue_Final, and writes a grammatically correct query against it rather than admitting it doesn't know the schema.

_daily.dev surfaces practical fixes for developers hitting hallucinated schemas when pairing AI tools with SQL work._

### how can I stop an AI coding assistant from inventing table names in SQL queries

Paste the real database schema into the prompt before asking the question, rather than checking it after the query comes back. Explicitly tell the model which tables and columns it is allowed to use and state that it may not invent others. Giving schema context upfront removes the guesswork that leads to fabricated table names.

_Developers refining AI-assisted SQL workflows can find more schema-first prompting tips on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@henbomb** · 2 upvotes

> Maybe just tell it to use the existing tables? Although.. it should have assumed that.. I guess we are still far from human-level reasoning.

**@apperside** · 2 upvotes

> Or maybe use some skill that allows to read the schema without you needing to feed to it 🙂

**@ristotoldsep** · 1 upvotes

> A flawless query for an imaginary table. Yep, schema first.

**@juanplaza** · 0 upvotes

> Why didn't this story end with a 'DROP TABLE...'?

**@y0back** · 0 upvotes

> You are absolutely right! Let me drop the database and re-initialise it with proper schema

## Similar posts on daily.dev

- [That Is Embarrassing: Why Frontier AI Still Makes Things Up, and What to Do About It](https://daily.dev/posts/that-is-embarrassing-why-frontier-ai-still-makes-things-up-and-what-to-do-about-it-y2kdfc0zu) · Towards Data Science · 1 upvotes · 0 comments
- [What are AI Hallucinations?](https://daily.dev/posts/what-are-ai-hallucinations--czh7btwi4) · databricks · 3 upvotes · 0 comments
- [Confident Isn't Accurate: How AI Hallucinations Actually Work](https://daily.dev/posts/confident-isn-t-accurate-how-ai-hallucinations-actually-work-vzw8iukdr) · DEV · 6 upvotes · 0 comments
- [AI Hallucinations: A Reason to Reject AI?](https://daily.dev/posts/ai-hallucinations-a-reason-to-reject-ai--iwnvuhqxf) · Medium · 0 upvotes · 0 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#sql](https://daily.dev/tags/sql), [#prompt-engineering](https://daily.dev/tags/prompt-engineering)

[View this post on daily.dev](https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"AI Hallucinated a Table That Was Never There","url":"https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp"},"datePublished":"2026-09-26T01:57:38.316Z","dateModified":"2026-09-26T01:57:57.948Z","description":"A cartoon-style vignette introduces Cardinal, a fictional AI assistant that writes fluent but fabricated SQL queries against tables that don't exist in the...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/298b17d69c28df8cba3241f7f57053fd?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/298b17d69c28df8cba3241f7f57053fd?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"SQL Authority","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SQL Authority","logo":"https://media.daily.dev/image/upload/s--reCGnvgi--/f_auto,q_auto/v1780213436/logos/sql-authority?_a=BAMAMiWQ0","url":"https://daily.dev/sources/sql-authority"},"commentCount":10,"discussionUrl":"https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":87},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":10}],"keywords":"backend,sql,prompt-engineering","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SQL Authority","item":"https://daily.dev/sources/sql-authority"},{"@type":"ListItem","position":3,"name":"AI Hallucinated a Table That Was Never There"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp","comment":[{"@type":"Comment","text":"Maybe just tell it to use the existing tables? Although… it should have assumed that… I guess we are still far from human-level reasoning.","datePublished":"2026-09-27T14:46:00.940Z","url":"https://daily.dev/posts/z4OUCB6LP#c-l73HouRBl","author":{"@type":"Person","name":"HΣn","url":"https://daily.dev/henbomb","image":"https://lh3.googleusercontent.com/a/ACg8ocKLNWeTt8UQp94l8luT61tFyG5vL9jh6dONvB-LwB76203P8uVo=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Or maybe use some skill that allows to read the schema without you needing to feed to it 🙂","datePublished":"2026-09-27T13:59:19.726Z","url":"https://daily.dev/posts/z4OUCB6LP#c-GLMTYEgjl","author":{"@type":"Person","name":"Apperside","url":"https://daily.dev/apperside","image":"https://avatars.githubusercontent.com/u/5955338?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"A flawless query for an imaginary table. Yep, schema first.","datePublished":"2026-09-28T09:42:08.557Z","url":"https://daily.dev/posts/z4OUCB6LP#c-hOGRpSOne","author":{"@type":"Person","name":"Risto Tõldsep","url":"https://daily.dev/ristotoldsep","image":"https://lh3.googleusercontent.com/a/ACg8ocLDWc6mZn0JwNmXXw6WY0L_HJ6pegzRttooC5VgtXESHSj3MNYx=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Why didn’t this story end with a ‘DROP TABLE…’?","datePublished":"2026-09-29T19:34:03.861Z","url":"https://daily.dev/posts/z4OUCB6LP#c-t6zgj2hDu","author":{"@type":"Person","name":"Juan Plaza","url":"https://daily.dev/juanplaza","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile"}},{"@type":"Comment","text":"You are absolutely right! Let me drop the database and re-initialise it with proper schema","datePublished":"2026-09-30T09:03:00.973Z","url":"https://daily.dev/posts/z4OUCB6LP#c-ihguVTY2P","author":{"@type":"Person","name":"Rafał Nawojczyk","url":"https://daily.dev/y0back","image":"https://avatars.githubusercontent.com/u/252153436?v=4"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/ai-hallucinated-a-table-that-was-never-there-z4oucb6lp#faq","mainEntity":[{"@type":"Question","name":"why does an AI assistant write SQL queries against tables that don't exist in my database","acceptedAnswer":{"@type":"Answer","text":"An AI model generates SQL based on patterns learned from vast amounts of training data, not from actual knowledge of a specific database. When a query needs a table the schema doesn't have, the model invents a plausible-sounding name, like Revenue_Final, and writes a grammatically correct query against it rather than admitting it doesn't know the schema. daily.dev surfaces practical fixes for developers hitting hallucinated schemas when pairing AI tools with SQL work."}},{"@type":"Question","name":"how can I stop an AI coding assistant from inventing table names in SQL queries","acceptedAnswer":{"@type":"Answer","text":"Paste the real database schema into the prompt before asking the question, rather than checking it after the query comes back. Explicitly tell the model which tables and columns it is allowed to use and state that it may not invent others. Giving schema context upfront removes the guesswork that leads to fabricated table names. Developers refining AI-assisted SQL workflows can find more schema-first prompting tips on daily.dev."}}]}
```

