Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
On production, don't execute queries as fast as you can. Read it at least 10 times, add where clause as well as limit at the end of your query then read it again. Always have a back up of the production database. Always read instruction to be executed in production dB.
-
Yeah, I tend to write queries as comments first, if I don’t need Intellisense. Or start with WHERE 1 = 0.
-
Did that at my first programming job during like my second or third week...but with the users' passwords. Thank god we had frequent backups for that database. Lesson learned, auto-commit is off, using transactions for any updates, and I ALWAYS write the statement as a select first, and then just change everything in front of the where clause...
-
Cvrsor2667yBest approach I have found is to just hire a DBA part time to run your PROD queries for you. This has stopped countless issues for me.
-
coderme6557y@rpcaldeira nope, I had to restore from the daily backup. Not cool, but I don't think anyone actually noticed other than me.
-
coderme6557y@BeardedFists Must be nice to be able to hire a guy just to write SQL. We don't have that luxury at our small web agency.
-
Cvrsor2667y@coderme You would have to find a DBA that can contract for about 3-5 hours per week. DBAs seem to love small contracts.
-
My manager taught me to always use transactions after a coworker had done something similar.. 3 lines to save your life:
begin transaction
Sql code here
--commit transaction
Rollback transaction
Most helpful advice ever 😊 -
coderme6557y@BeardedFists That is a neat/weird pro tip! Thanks! That would be helpful in setting up Flyway / MySQL CI.
-
coderme6557y@MrCSharp Between you and @riekena I owe you guys. I took a SQL class at school (PLSQL to be exact) and the professor didn't discuss the actual usefulness of transactions. Not even sure he covered them at all.
-
Change the email to someone you don't like and rerun the SQL and blame it in him. Easy solution
Related Rants
For some idiotic reason, I ran
UPDATE users
SET email="myname@mycompany.com"; in production.
No where clause. Oh drat.
rant
screwup
sql
backup
wk98
ifix