December 19, 2012 at 4:40 am
palotaiarpad (12/19/2012)
Could someone please explain, why is the identity resetted after a truncate?
Because conceptually, TRUNCATE TABLE is closer to DROP / CREATE than to DELETE.
December 19, 2012 at 5:05 am
Easy one.. Remembering basics...
--
Dineshbabu
Desire to learn new things..
December 19, 2012 at 5:30 am
SQL Kiwi (12/19/2012)
Another good one. 19% wrong right now :blink:
Yes, a good one. And in the last 6 hours the wrong rate has grown from 19% to 27%, which seems rather high for such an easy question.
Tom
December 19, 2012 at 5:44 am
palotaiarpad (12/19/2012)
why is the identity resetted after a truncate? For me is a possible source of inconsitency.
As Lokesh has already explained, resetting the identity seed is a characteristic of the 'truncate' command. If you want to retain the seed then you use 'delete' instead. So, there's no inconsistency, it is just a case of using the right command according to your needs.
At least you learnt something, so from that point of view it is a good question. 😉
December 19, 2012 at 7:01 am
palotaiarpad (12/19/2012)
I'm also wrong, but i learned something. Could someone please explain, why is the identity resetted after a truncate? For me is a possible source of inconsitency.
Hello, if resetting the identity is a possible source of inconsistency you may try using DELETE instead of TRUNCATE. DELETE will remove the data without resetting the identity.
December 19, 2012 at 7:06 am
Thanks for the easy one today.
December 19, 2012 at 7:29 am
Hmm, I answered too quickly (being on holiday now), thinking that without specifying the column list, the INSERT would expect values for both columns and hence would fail the inserts (even though an identity insertion wouldn't be allowed either). Doh. Thanks for what should have been an easy one!
December 19, 2012 at 8:04 am
Good Question, learned something today.
December 19, 2012 at 9:55 am
Weird, I was so sure I recently got a question wrong exactly because I thought truncate reseeded the identity and it actually didn't. Guess I was just confused. 😛
Thanks for the good question, apparently I really needed to learn that one.
December 19, 2012 at 10:37 am
December 19, 2012 at 12:06 pm
It was easy, but really good for getting back to the basics. Thanks!
December 19, 2012 at 8:47 pm
Good, straight-forward question on the basics. I'm surprised how many have gotten this wrong. I guess that means there are a lot of people learning a valuable point.
December 20, 2012 at 2:11 am
from beginning............
December 20, 2012 at 6:32 am
Thanks for memorized .
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
December 22, 2012 at 1:22 am
i think the answer will be "invalid object" as in last query we are dropping the table.
Viewing 15 posts - 16 through 30 (of 35 total)
You must be logged in to reply to this topic. Login to reply