yakut
yakut

Reputation: 47

Sybase ASE 15.7 reorg rebuild

Is there a way to reorg rebuild sybase tables automatically? Can we do it with the job scheduler or script?

Upvotes: 0

Views: 2019

Answers (1)

Mike Gardner
Mike Gardner

Reputation: 6651

Reorgs can be run using the Job Scheduler, or via batch/shell scripts. You will have to generate the table list you wish to reorg programatically, as there is not a command to do this automatically.

There are a couple approaches, one is to use the 'optdiag' command to check table health, and use that information to dynamically decide which tables to reorg. Check my answer to this question for more on 'optdiag'

Another method is just reorg everything, which I only recommend for small databases. A script can be generated to do this with the following SQL First, the database option "into/bulkcopy/pllsort" must be set to true to be able to run reorg rebuild

use master
go
sp_dboptions <dbname>, "select into/bulkcopy/pllsort", true
go

The following generates a script that can then be run against the server to rebuild the tables. Depending on how you generate this, you may have to remove the first row of the file if it contains column headers.

use <DBNME>
go

set nocount on
select "reorg rebuild "+ name + char(10) + "go"
from sysobjects
where name not like "sys%"                   //excludes system tables
go

Upvotes: 0

Related Questions