@argv_minus_one@mastodon.sdf.org
Post #4181558
2026-07-29 03:33 UTC
I do enjoy doing fun #SQL tricks to clean up a database. 😌
Fun fact: if you have a newline-separated list of identifiers you need to use in a query, you can turn it into comma separated by piping it to `tr '\n' ','`. Then you can use it in a SQL IN clause.
But beware that this only works if your list contains nothing but integers! Otherwise you need to wrap string quotes around the lines first, escape them, etc, lest you fall prey to SQL injection.
#database #programming
Replies (1)
-
@argv_minus_one@mastodon.sdf.org 2026-07-29 03:34
Another fun fact: you can start a transaction, make some changes, check that the changes had the effect you intended, and then commit or rollback. Transactions aren't just for applications! You can use them interactively too. #SQL #database #programming