Unix Technical Forum

Can we rely on object_id always increasing?

This is a discussion on Can we rely on object_id always increasing? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, When we create new user objects, can we assume that the object_id will constantly increase? In other words, ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-06-2008, 03:04 PM
rajigopal@gmail.com
 
Posts: n/a
Default Can we rely on object_id always increasing?

Hi,

When we create new user objects, can we assume that the object_id will
constantly increase? In other words, if I create a table and then a
view, is it true that the object_id of the view if I query sysobjects
view will be greater than the object_id of the table?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-06-2008, 03:04 PM
czytacz
 
Posts: n/a
Default Re: Can we rely on object_id always increasing?

no,
if you:

1) create table A
2) create view V basis on A
3) drop table A
4) create table A (new 'A', the same name as A)

the new A table will have bigger objectID than view V



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-06-2008, 03:04 PM
rajigopal@gmail.com
 
Posts: n/a
Default Re: Can we rely on object_id always increasing?

On Mar 4, 11:33*am, czytacz <redak...@dupa.gazeta.pl> wrote:
> no,
> if you:
>
> 1) create table A
> 2) create view V basis on A
> 3) drop table A
> 4) create table A (new 'A', the same name as A)
>
> the new A table will have bigger objectID than view V


What you're saying then is that objects created will have an ever-
increasing object_id, right? Meaning, ordering by create_date is the
same as ordering by object_id....correct?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-06-2008, 03:04 PM
David Portas
 
Posts: n/a
Default Re: Can we rely on object_id always increasing?

On 4 Mar, 19:10, rajigo...@gmail.com wrote:
> Hi,
>
> When we create new user objects, can we assume that the object_id will
> constantly increase? In other words, if I create a table and then a
> view, is it true that the object_id of the view if I query sysobjects
> view will be greater than the object_id of the table?
>
> Thanks!


Why would you want to assume that though? Even if it were true that
object_id matched creation order it's still a dangerous assumption.
Some people use the Management Studio UI to make modifications to
objects and Management Studio will sometimes drop and recreate objects
and sometimes not.

I don't condone the use of Management Studio in this way but it does
explain why the object_id might increment unexpectedly - or perhaps
fail to increment when you expect it to.

--
David Portas
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-06-2008, 03:04 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Can we rely on object_id always increasing?

(rajigopal@gmail.com) writes:
> When we create new user objects, can we assume that the object_id will
> constantly increase? In other words, if I create a table and then a
> view, is it true that the object_id of the view if I query sysobjects
> view will be greater than the object_id of the table?


It does not seem so. I ran this query on a database that I have:

select name, crdate, id from sysobjects where type = 'U' order by crdate

Output:

abaconfigproperties 2008-02-03 19:36:39.107 1977058079
abaconfigsettings 2008-02-03 19:36:39.153 2009058193
abahistsysobjects 2008-02-03 19:36:39.217 2073058421
abainstallhistory 2008-02-03 19:36:39.293 2105058535
abaobjecttypes 2008-02-03 19:36:39.357 5575058
abasslabels 2008-02-03 19:36:39.403 37575172
abasubsystems 2008-02-03 19:36:39.450 85575343
abasysobjects 2008-02-03 19:36:39.513 133575514



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:48 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com