July 16, 2004

Daily Tip: Starting a table over again.

If you want to clear out a table in M$ SQL so that the key starts back over at 1, use TRUNCATE instead of DELETE FROM in your query

TRUNCATE TABLE is functionally identical to DELETE statement with no WHERE clause: both remove all rows in the table. But TRUNCATE TABLE is faster and uses fewer system and transaction log resources than DELETE.
Post Info

Tagged As Database, Tip

Comments are Open (4)

Posted at 09:15 AM

Comments

chet

In classic usenet style, though, I'll point out that a far better solution is to export all your data to vanilla SQL, erase MS SQL, and install Postgres. :)

Tony

Fuck Postgres. I'd take MySQL any day of the week.

But MS SQL isn't as bad as some of the other M$ offerings. I'd rather use MS SQL over Oracle any day of the week. (that's because I've never bothered to learn Oracle. And I really don't plan to.)

chet

MS SQL may not be as bad as some of the software foisted on an unsuspecting world by Redmond, but that doesn't make it a good database.

Seriously, pick up on PostgreSQL, just for comparison's sake. It's amazingly good, very solid, and quite scalable -- and, of course, both free (as in beer) and Free (as in speech). Dorman and I used it on a site last year that's doing 3mm hits a day with 150K registered users. (One web server, one DB server, both running Debian; bet you can guess what web server we used...)

Tony

Yeah, I just ran across an interesting site today talking about the numerous MySQL "gotchas". Many more than I was aware of. Enough to give me pause.

I will have to look into Postgres. Although I don't have any box at this point to install it on (well, I could install it on the home mac.)

My DB of choice up to this point has been MySQL. Postgres and MS SQL were in the middle of the pack. My Most-Hated-DB up to this point is Oracle. (It will continue with it's MHDB status as well.)

Given the number of places where MS SQL was the default DB, given the internal network architecture, I've worked a fair deal with MS SQL. And it's never made me hate it. Never made me LOVE it, but never HATE it. Not like the vitriol I have for Oracle.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu