Ooops – did I just delete the LMS database?

I’m always wary of doing bulk changes to the bibliographic records via SQL, so I tend to be fairly cautious.
Anyway, we’d got nearly 100,000 bib records that need rejiggering (ISBN in the wrong field), so I knocked up a Perl script to do the deed. After it had changed a few hundred records, I connected to the database and ran the following SQL…
set rowcount 10
select * from bib where tag = “011”

The last thing I want to do is pull back everything with a 011 tag, so the “set rowcount” ensures only the first 10 results are returned. The output looks good, so I decide to check the size of the transaction log…
sp_dbspace
We use Sybase and that command shows the size of the main LMS database and the transaction log. The transaction log size looks fine and I minimise the window. However, my subconscious shouts out “something’s wrong!”, so I maximise the SQL window and look at the output again…
name: horizon
data MB: 5500.00
used MB: 54.68
percent: 0.99%
log MB: 300.00
log used MB: 88.40
log pct: 29.47%

My eyes automatically jump to the end of the output: “So, the transaction log is 29.47% full… that’s nothing to worry about…”
My eyes then wander up and my brain takes about 2 seconds to spot what’s really wrong — our entire LMS database is just 54.68MB!!! “That can’t be right… it should be at least 4,800MB!!!”
The colour drains from my face as the possibility that one of the SQL commands in my Perl script has nuked our entire database enters my mind. I sit motionless in my chair waiting for the inevitable phone call from a member of staff: “Dave… is there something wrong with Horizon?”
Then, in the space of about 30 seconds, I go through all seven stages of grief…
1) shock (“I can’t believe this has happened”)
2) denial (“maybe someone else did it?”)
3) bargaining (“I wonder if I can bribe someone else to take the blame?”)
4) guilt (“OMG — IT’S ALL MY FAULT!!!”)
5) anger (“damn it — this didn’t happen when I ran the script on the test database!”)
6) depression (“this won’t sound good when I apply for a new job and they asked me why I was fired from my previous job”)
7) acceptance and hope (“the time is right for a major career change”)
…so, can anyone guess what happened next?

5 thoughts on “Ooops – did I just delete the LMS database?”

  1. A good backup solves 99% of all known problems (without the Library staff necessarily even knowing ;-))……

  2. Solution 2) denial, was the right one; for just then, folks from SirsiDynix called to say they were very sorry but an assistant confused your database with another client’s database, and, you know… that happens.

  3. Some good suggestions and I like the idea of starting again with a clean slate 🙂
    What I never knew, until today, was that changing the “rowcount” value can affect the the output of Sybase stored procedures. So, that “rowcount 10” was causing the “sp_dbspace” to report back incorrect values for the size of the database.
    In other words, thankfully, I hadn’t deleted the database 🙂
    That means my biggest IT gaffe is still the following (which occurred on Christmas Eve 1995) whilst I was on work placement in an IT Dept…
    Being Xmas Eve, I was keen to head off home. As the floppy disk drive on my home PC was playing up and refusing to format disks (but was reading them okay), the last thing I did before leaving the office was to boot my work PC into DOS and typed in the command to format the floppy…
    format
    The “are you sure?” prompt came up and I pressed “Y” without even thinking. A few minutes later I thought to myself “this is taking a long time”… followed by “why isn’t the floppy drive light on?”… followed by “bugger — I’ve just formatted the C: drive!”
    Thankfully, there was a copy of Norton Utilities in the office and it managed to recover everything 🙂

Comments are closed.