Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > Help .... can't expand a production DB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-12-08, 16:46
dogboy11 dogboy11 is offline
Registered User
 
Join Date: Feb 2004
Posts: 26
Help .... can't expand a production DB

Trying to expand a production database and I get the following error:

Attempt to insert duplicate key row in object 'sysusages' with unique index
'sysusages'

Anyone know what the issue is on this? Thanks.


DB
__________________
Dogboy
Reply With Quote
  #2 (permalink)  
Old 06-13-08, 11:45
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 370
Quote:
Originally Posted by dogboy11
Trying to expand a production database and I get the following error:

Attempt to insert duplicate key row in object 'sysusages' with unique index
'sysusages'

Anyone know what the issue is on this? Thanks.


DB

Did you try a control-c when you were doing an alter database? This is a bit serious if you did as you may end up having a sysusages entry which is not valid.
Reply With Quote
  #3 (permalink)  
Old 06-13-08, 11:46
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 370
Also, post the command which you are trying. Guessing its alter database blah.

Most probably your problem is the memory structure of the database conflicts with the sysusages table. And usually this happens when you did a control-c in the middle of an alter database.
You can try this if thats the case. But dont assume its a simple operation.

First, a select * from sysusages for the dbid of the user database. Then, execute dbcc dbtable for the database. This requires sybase_ts_role to be granted and set:


1>use master

2>go

1>sp_role "grant", "sybase_ts_role", sa

2>go

1>set role "sybase_ts_role" on

2>go

1>dbcc traceon(3604)

2>go

1>dbcc dbtable(dbname)

2>go

1>dbcc traceoff(3604)

2>go



Compare the number of rows in the sysusages table in the master database for this dbid with the number of dm_segmap entries in the output from dbcc dbtable for the database. They should be equal. If they are not equal, then execute the following command:



1>dbcc dbrepair(<dbname>, remap)

2>go



This command is used to update the dbtable structure sysusages information by reading the current sysusages information for the database name.



It is a good idea to put the user database in single-user mode prior to running the dbcc dbrepair. After the dbcc dbrepair is run, take the single-user option off the database and the database should be able to be altered successfully.

Last edited by trvishi : 06-13-08 at 12:20.
Reply With Quote
  #4 (permalink)  
Old 06-13-08, 12:22
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 370
Also, DO NOT SHUT DOWN the SERVER until you fix this.
Reply With Quote
  #5 (permalink)  
Old 06-13-08, 16:31
dogboy11 dogboy11 is offline
Registered User
 
Join Date: Feb 2004
Posts: 26
I figured the problem out .... I don't remember ever breaking out of an "alter database" command .... I try not to do that .... that aside I did do a sp_dbremap dbname and that seemed to fix it. Thanks for your help.

DB
__________________
Dogboy
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On