Subject: Sybase FAQ: 4/16 - section 3
Date: 1 Sep 1997 06:01:50 GMT
Summary: Info about SQL Server, bcp, isql and other goodies
Posting-Frequency: monthly

Archive-name: databases/sybase-faq/part4
URL: http://reality.sgi.com/pablo/Sybase_FAQ

                          Q3.1: HOW TO SET _TS ROLE_
                                       
   
     _________________________________________________________________
   
   Some _DBCC_ commands require that you set _TS Role_ in order to run
   them. Here's how to set it:
   
   Login to Server as _sa_ and perform the following:
   

sp_role "grant", sybase_ts_role, sa
go
set role "sybase_ts_role" on
go

   
     _________________________________________________________________

                         Q3.2: DBCC COMMAND REFERENCE
                                       
   
     _________________________________________________________________
   
   If you know of any more DBCC Commands, please mail to pablo@sgi.com.
   For your consumption here they are, use at your own risk:
   
     * allocdump( dbid, page )
     * bhash( { print_bufs | no_print }, bucket_limit )
     * buffer( [ dbid ][, objid ][, nbufs ], printopt = { 0 | 1 | 2 },
       buftype )
     * bytes( startaddress, length )
     * checkalloc[( dbname [, fix | nofix ] ) ]
     * checkcatalog[( dbname )]
     * checkdb[( dbname [, skip_ncindex ] ) ]
     * checktable( tablename | tabid [, skip_ncindex ] )
     * cursorinfo(cursor_level, cursor_name) where
          + cursor_level - level of nesting. -1 is all nesting levels
     * dbinfo( [ dbname ] )
     * dbrepair( dbid, option = { dropdb | fixindex | fixsysindex },
       table, indexid )
     * dbtable( dbid )
     * delete_row( dbid, pageid, delete_by_row = { 1 | 0 }, rownum )
     * des( [ dbid ][, objid ] )
     * engine(eng func) where _eng func_ may be:
          + "online"
          + "offline"
     * extentcheck( dbid, objid, indexid, sort = {1|0} )
     * extentdump( dbid, page )
     * extentzap( dbid, objid, indexid, sort )
     * findnotfullextents( dbid, objid, indexid, sort = { 1 | 0 } )
     * fix_al( [ dbname ] )
     * help( dbcc_command )
     * ind( dbid, objid, printopt = { 0 | 1 | 2 } )
     * indexalloc(tablename|tabid, indid, [full | optimized | fast],[fix
       | nofix])
     * listoam(dbid, table_id, indid) - may supply dbname/tablename
       rather than id
     * locateindexpgs( dbid, objid, page, indexid, level )
     * lock - print out lock chains
     * log(
       [dbid][,objid][,page][,row][,nrecords][,type={-1..36}],printopt={0
       |1} )
     * memusage
     * netmemshow( option = {1 | 2 | 3} )
     * netmemusage
     * newalloc( dbname, option = { 1 | 2 | 3 } )
     * page( dbid, pagenum [, printopt={0|1|2} ][, cache={0|1} ][,
       logical={1|0} ] )
     * pglinkage( dbid, start, number, printopt={0|1|2}, target,
       order={1|0} )
     * pktmemshow( option = {spid} )
     * procbuf( dbid, objid, nbufs, printopt = { 0 | 1 } )
     * prtipage( dbid, objid, indexid, indexpage )
     * pss( suid, spid, printopt = { 1 | 0 } )
     * rebuildextents( dbid, objid, indexid )
     * resource
     * setkeepalive(# minutes) - for use on Novell with TCP/IP.
     * show_bucket( dbid, pageid, lookup_type )
     * tab( dbid, objid, printopt = { 0 | 1 | 2 } )
     * tablealloc(tablename|tabid, [full | optimized | fast],[fix |
       nofix])
     * traceoff( tracenum [, tracenum ... ] )
     * traceon( tracenum [, tracenum ... ] )
     * tune( option, value ) - switch on any option immediately without
       having to reboot the SQL Server. Switches correspond to the old
       (pre-System 11) _buildmaster -yall_ minus the _c_ prefix
       
       For example _option_ may be:
          + indextrips
          + oamtrips
          + datatrips
          + schedspins
          + bufwashsize
          + sortbufsize
          + sortpgcount
          + maxscheds
          + max_retries
     * undo( dbid, pageno, rowno )
       
   
     _________________________________________________________________

                           Q3.4: FIXING A MUNGED LOG
                                       
   
     _________________________________________________________________
   
     _Sybase Technical Support states that this is extremely dangerous as
     it "jacks up the value of the timestamp" which is used for recovery
     purposes. This may cause potential database corruption if the system
     fails while the timestamp rolls over.
     
     In 4.9.2, you could only run the dbcc rebuild_log command once and
     after that you would have to use bcp to rebuild the database
     
     In System 10, you can run this command about 10 times.
     
     In System 11 I (FAQ maintainer) tried it about 20 times and no
     problem. _

1> use master
2> go
1> select count(*) from _your_database_..syslogs
2> go

 -----------
 _some number_

1> sp_configure "allow updates",1
2> go
1> reconfigure with override  /* for system 10 and below */
2> go

1> begin tran
2> go

_/* Save the following status to be used later... */_
1> select _saved_status_=status from sysdatabases where name = "_your_database_
"
2> go
1> update sysdatabases set status = -32768 where name = "_your_database_"
2> go
1> commit tran
2> go
1> shutdown
2> go

1> dbcc rebuild_log (_your_database_, 0, 0)
2> go
DB-LIBRARY error (severity 9):
   Unexpected EOF from SQL Server.

1> dbcc rebuild_log (_your_database_, 1, 1)
2> go
DBCC execution completed. If DBCC printed error messages, see your System
Administrator.


1> use _your_database_
2> go
1> select count(*) from syslogs
2> go

 -----------
           1

1> begin tran
2> go
1> update sysdatabases set status = _saved_status_ where name = "_your_database_
"
2> go
(1 row affected)
1> commit tran
2> go
1> shutdown
2> go

   
     _________________________________________________________________
-- 
Pablo Sanchez              | Ph # (415) 933.3812        Fax # (415) 933.2821
pablo@sgi.com              | Pg # (800) 930.5635  -or-  pablo_p@pager.sgi.com
===============================================================================
I am accountable for my actions.   http://reality.sgi.com/pablo [ /Sybase_FAQ ]
