Do You Need An AI Assistant?
Artificial Intelligence has been over hyped the last several years. But one of the bright, shining spots for AI is acting as an assistant. a super-powerful IDE, when working with a database.
Example
You want to find your top three customers in the Sakila database. This database has been used for decades in the MySQL world.
As your question in English (or another language)
![]() |
The '@ai' directs the rest of the prompt to the DBeaver Artificial Intelligence Assistant |
See the generated SQL
![]() |
Here is the generated Structured Query Language |
And get the results.
![]() |
Now we have the top three customers without having to write any SQL directly |
Fixing Mistakes
Occasionally, you may 'fat finger' a query. I will take the query from above and change first_name to just first.
SELECT
c.customer_id,
c.first,
c.last_name,
SUM(p.amount) AS total_revenue
FROM
customer AS c
JOIN
payment AS p ON c.customer_id = p.customer_id
GROUP BY
c.customer_id, c.first_name, c.last_name
ORDER BY
total_revenue DESC
LIMIT 3;
When I attempt to execute the query, it fails.
SQL Error [1054] [42S22]: Unknown column 'c.first' in 'field list'
Thankfully, the DBeaver AI assistant has a button for such cases.
Selecting AI Explain and Fix asks for help.
An AI Assistant can be a tremendous aid when you are working with MySQL.
Comments
Post a Comment