Reply to post: Re: Beer...

We've found it... the last shred of human decency in an IT director – all for a poxy Unix engineer

Loyal Commenter Silver badge

Re: Beer...

Why did the senior DBA let him do it if he was really looking over his shoulder?

More to the point, why did the senior DBA teach the junior DBA to use TRUNCATE, especially on live data.

If you know you're on a database which is definitely not a production one, preferably on a server that definitely isn't a live one, and you've made sure that you don't have another session open on any live server anywhere that you might accidentally type a command into, then maybe you might use TRUNCATE, but even then, you'd probably DROP or DELETE FROM instead, unless the table in question was huge, or the hardware very slow, because typically, if you're doing something on a test system, you'd want to replicate what you'd do, and the way you'd do it, on a live system.

Typically, if doing anything that involves deleting data from a live database, the very first thing you'd do is make a copy of the data you're about to operate on. The senior DBA should have been teaching teh junior that as a matter of course. If not making a copy of the entire table, then running your DELETE statement as a SELECT first to copy that data somewhere else.

Then, of course, you'd check for any cascading delete constraints...

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

SUBSCRIBE TO OUR WEEKLY TECH NEWSLETTER

Biting the hand that feeds IT © 1998–2020