3 ms·
I wonder whether tooling that is commonly used to query a database should detect these common mistakes and warn you. `psql` could easily pop up a warning "Are y
by photonios 8y ago
I wonder whether tooling that is commonly used to query a database should detect these common mistakes and warn you. `psql` could easily pop up a warning "Are you sure you wanna drop this entire table?".
An alternative would be for databases to add an option to prevent accidental deletion. When enabled, would make it impossible to truncate or delete entire tables. I would enable such a setting on my production databases.
- Jeremy1026 8y agoWe have code in place to reject any SQL query without a where clause.
- seanwilson 8y agoI'm always surprised this isn't default. Imagine "rf" deleted everything if you didn't specify a file.
- dragonwriter 8y agoA front end that (perhaps only had a mode that) required delete or update queries to be preceded by select queries, and then styled as “DELETE IT;” or “UPDATE IT SET ...;” which use the FROM and (if present) WHERE clause from the preceding SELECT would be interesting.
- photonios 8y agoThis seems such a good idea that I doubt nobody ever tried to implement something like this. At least for PostgreSQL, someone tried: https://www.postgresql.org/message-id/12104.1150425319%40sss.pgh.pa.us https://www.postgresql.org/message-id/12104.1150425319%40sss... But it doesn't seem like it got much serious attention.
- dragonwriter 8y agoThat seems to be someone asking for a back-end change to prevent such queries, not a front-end change. I think front-end makes sense, where SQL is a UI, not back-end, where it is an API.
- Torgo 8y agoJetBrains DataGrip does put up a warning like this before you can do a DELETE on a table, unadorned by a WHERE clause.
- jimrhods23 8y agoDataGrip is my #1 DB tool for my team for reasons like this.