SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Reindexing..


Reindexing..

Author
Message
hb21l6
hb21l6
SSC Veteran
SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)

Group: General Forum Members
Points: 202 Visits: 294
if i have a table ( call it tableA) and a second table ( call it tableB)

TableA has these fields
ID, Int, Key
FirstName, nvarchar(50)
LastName, nvarchar(50)
Address, nvarchar(250)

TableB has these fields
ID, Int, Key
TableAID, int,
AccountNo, nvarchar(50)
SortCode, nvarchar(50)
Bank, nvarchar(250)
etc

the two tables are not joined in a relationship.
If I reindex tableA, it will mess up all the indexes relating to table B

or did i missing something?

thanks
Dave
SanjayAttray
SanjayAttray
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4733 Visits: 1619
No, it won't. SQL Server stores index information of each table separately.

SQL DBA.
Jason Selburg
Jason Selburg
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4389 Visits: 4113
And indexes are "pointers" to the physical location of the data. Think of them as floating on another layer or more appropriately as the index in the back of a book. If you move chapters/pages around the index entry for "Chapter 2" is still pointing to chapter 2 even if you've added 10 pages to chapter one. SQL Server will handle those changes on it's own. And like sanjay said, each "book" or table's indexes are managed seperately. So if table A refers to table B's chapter 2, it doesn't matter to table A where that physically is because it points to the index "Chapter 2" and not the data itself.



I may have rambelled on here, but I hope it makes sense.

______________________________________________________________________

Personal Motto: Why push the envelope when you can just open it?

If you follow the direction given HERE you'll likely increase the number and quality of responses you get to your question.

Jason L. Selburg
hb21l6
hb21l6
SSC Veteran
SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)

Group: General Forum Members
Points: 202 Visits: 294
thanks for the replies guys.

urm.. yes and no, i think??

example. ( data in the tables)

tableA
ID, Name, address1, Address2
1, dave, somestreet, hull
3, frank, anotherstreet, leeds
4, john, yetanotherstreet, scunthorpe

tableB
ID, TableAID, AccountNo, SortCode, Amount,

1, 1, 00000001, 123456, 100
2, 3, 00000002, 123456, 100
3, 4 00000003, 123456, 100


if i re-index tableA so the new indexes are 1,2 and 3 instead of 1, 3 and 4
they wouldn't relate to tableB anymore. making them wrongly related tables?

Am i getting it all wrong? are there other SQL indexes other then the ones i see on the tables?

thanks
Dave
Jason Selburg
Jason Selburg
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4389 Visits: 4113
Dave,

You are indeed getting it wrong.Hehe

You're confusing Foreign Keys with Indexes.

Read up on BOL on these topics and ask more questions after that. :-)

______________________________________________________________________

Personal Motto: Why push the envelope when you can just open it?

If you follow the direction given HERE you'll likely increase the number and quality of responses you get to your question.

Jason L. Selburg
GSquared
GSquared
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30683 Visits: 9730
Aha! You're using the wrong word. The word you want is "identities", not "indexes". ("Indexes" is probably the right word in some other context, but in SQL, it's not.)

Yes, if you change the identity values in TableA, that will mess up TableB. You can handle that by adding a foreign key constraint to TableB:


alter TableB
add constraint FK_TableA foreign key (TableAID) references dbo.TableA(ID) on update cascade



Then, if you update TableA's ID, it will also update TableB.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
hb21l6
hb21l6
SSC Veteran
SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)SSC Veteran (202 reputation)

Group: General Forum Members
Points: 202 Visits: 294
doh... i've always called them Indexes, or IDs, "note to self - call them identities"

sorry all, my bad..

thanks
Dave
GSquared
GSquared
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30683 Visits: 9730
"IDs" is a valid name for them. Same as "identities".

"Indexes", on the other hand, are a means of storing parts of a table in a separate structure, to speed up looking up the data from the table. (That's an oversimplification, but it goes in the right direction.) Just like the index of a book, really.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search