Unix Technical Forum

Recordset's Order and Database's Physical Order?

This is a discussion on Recordset's Order and Database's Physical Order? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi,guys! I have a table below: CREATE TABLE rsccategory ( categoryid NUMERIC(2) IDENTITY(1,1), categoryname VARCHAR(20) NOT NULL, PRIMARY KEY(categoryid) ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:39 PM
Rhett Liu
 
Posts: n/a
Default Recordset's Order and Database's Physical Order?

Hi,guys!

I have a table below:
CREATE TABLE rsccategory
(
categoryid NUMERIC(2) IDENTITY(1,1),
categoryname VARCHAR(20) NOT NULL,
PRIMARY KEY(categoryid)
)
Then I do:
INSERT rsccategory(categoryname) VALUES('url')
INSERT rsccategory(categoryname) VALUES('document')
INSERT rsccategory(categoryname) VALUES('book')
INSERT rsccategory(categoryname) VALUES('software')
INSERT rsccategory(categoryname) VALUES('casus')
INSERT rsccategory(categoryname) VALUES('project')
INSERT rsccategory(categoryname) VALUES('disert')
Then SELECT * FROM rsccategory in ,I can get a recordeset with the
'categoryid' in order(1,2,3,4,5,6,7)
But If I change the table definition this way:
categoryname VARCHAR(20) NOT NULL UNIQUE,
The select result is in this order (3,5,7,2,6,4,1),and 'categoryname '
in alphabetic.
Q:why the recordset's order is not the same as the first time since
'categoryid' is clustered indexed.

If I change the table definition again:
categoryname VARCHAR(20) NOT NULL UNIQUE CLUSTERED
the result is the same as the first time.
Q:'categoryname' is clustered indexed this time,why isn't in alphabetic
order?

I am a newbie in ms-sqlserver,or actually in database,and I do have
sought for the answer for some time,but more confused,Thanks for your
kind help in advance!



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:39 PM
Tibor Karaszi
 
Posts: n/a
Default Re: Recordset's Order and Database's Physical Order?

I assume the last post was a mistake or a late delivery from a news server, as you've got several
replies to your question. If you have question on any of the replies, please ask along with the
reply (and not just post the question again).

--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver


"Rhett Liu" <liuchenggang@mail.biti.edu.cn> wrote in message news:bikuok$9uv$1@mail.cn99.com...
> Hi,guys!
>
> I have a table below:
> CREATE TABLE rsccategory
> (
> categoryid NUMERIC(2) IDENTITY(1,1),
> categoryname VARCHAR(20) NOT NULL,
> PRIMARY KEY(categoryid)
> )
> Then I do:
> INSERT rsccategory(categoryname) VALUES('url')
> INSERT rsccategory(categoryname) VALUES('document')
> INSERT rsccategory(categoryname) VALUES('book')
> INSERT rsccategory(categoryname) VALUES('software')
> INSERT rsccategory(categoryname) VALUES('casus')
> INSERT rsccategory(categoryname) VALUES('project')
> INSERT rsccategory(categoryname) VALUES('disert')
> Then SELECT * FROM rsccategory in ,I can get a recordeset with the
> 'categoryid' in order(1,2,3,4,5,6,7)
> But If I change the table definition this way:
> categoryname VARCHAR(20) NOT NULL UNIQUE,
> The select result is in this order (3,5,7,2,6,4,1),and 'categoryname '
> in alphabetic.
> Q:why the recordset's order is not the same as the first time since
> 'categoryid' is clustered indexed.
>
> If I change the table definition again:
> categoryname VARCHAR(20) NOT NULL UNIQUE CLUSTERED
> the result is the same as the first time.
> Q:'categoryname' is clustered indexed this time,why isn't in alphabetic
> order?
>
> I am a newbie in ms-sqlserver,or actually in database,and I do have
> sought for the answer for some time,but more confused,Thanks for your
> kind help in advance!
>
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 05:39 PM
Rhett Liu
 
Posts: n/a
Default Re: Recordset's Order and Database's Physical Order?

Tibor Karaszi дµÀ:
> I assume the last post was a mistake or a late delivery from a news server, as you've got several
> replies to your question. If you have question on any of the replies, please ask along with the
> reply (and not just post the question again).
>

late delivery,
you are right,
And you are so kind!Wishes!

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 10:26 AM.


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