It speeds up one off throw away software work that I need to do. Here's a concrete example from work recently:
> I need help writing a SQL statement. I'm using Postgresql and the database has a table called `<name>` with dozens of columns such as: `..._id`, `..._id`, `..._id`, `..._id`, etc. The columns are of type uuid. Separately I also have a list of thousands of uuids and I want to check if any values in my list are used in any of the fields on the `<name>` table. Is there a compact SQL statement that allows me to do this? I would like to avoid listing out all the columns by name.
GPT-4 responed:
> Yes, you can achieve this by querying the information_schema.columns to get the list of columns dynamically and then use a combination of string_agg, EXECUTE, and FORMAT functions to build and execute the SQL query. Here's an example:
I ran it as written and it worked great!
Could I have done this on my own? Sure, but it would have taken a few google searches, reading, trial and error to build up the query, probably 30 or 40 minutes more than just asking GPT-4 to write the query.
Actually that model seems particularly good at writing SQL queries FYI, I could totally see a chat layer on top of a relational database writing all the SQL with no humans in the loop, just natural language --> LLM --> SQL.
> I need help writing a SQL statement. I'm using Postgresql and the database has a table called `<name>` with dozens of columns such as: `..._id`, `..._id`, `..._id`, `..._id`, etc. The columns are of type uuid. Separately I also have a list of thousands of uuids and I want to check if any values in my list are used in any of the fields on the `<name>` table. Is there a compact SQL statement that allows me to do this? I would like to avoid listing out all the columns by name.
GPT-4 responed:
> Yes, you can achieve this by querying the information_schema.columns to get the list of columns dynamically and then use a combination of string_agg, EXECUTE, and FORMAT functions to build and execute the SQL query. Here's an example:
I ran it as written and it worked great!
Could I have done this on my own? Sure, but it would have taken a few google searches, reading, trial and error to build up the query, probably 30 or 40 minutes more than just asking GPT-4 to write the query.
Actually that model seems particularly good at writing SQL queries FYI, I could totally see a chat layer on top of a relational database writing all the SQL with no humans in the loop, just natural language --> LLM --> SQL.