Computing.Net > Forums > Database > Script to check database status

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Script to check database status

Reply to Message Icon

Original Message
Name: ramup
Date: September 27, 2008 at 13:36:51 Pacific
Subject: Script to check database status
OS: IBM-AIX
CPU/Ram: 200
Manufacturer/Model: IBM
Comment:

Hi All,

Can any one tell me the script from UNIX that will login to Sybase server and checks the all databases and return the status and sends mail.or if any databases goes to suspect/corrupt mode i need to get alert mail


Report Offensive Message For Removal


Response Number 1
Name: KirstyN
Date: October 1, 2008 at 18:07:56 Pacific
Reply:

Here is an example of a startup/shutdown script for Sybase:
Code:

#!/bin/sh
#
# Startup script for Sybase SQL server
#

#
# Adjust tcp's keepalive param to 10 mins for PCs which disconnect unexpectedly.
# Sun recommend that the value be set no lower than 10 minutes or performance
# may be affected.
#
/usr/sbin/ndd -set /dev/tcp tcp_keepalive_interval 600000

#
# Path to Sybase and install.
#
SYBASE=/usr/sybase

ISQL=$SYBASE/bin/isql

INSTALL=$SYBASE/install

export SYBASE ISQL INSTALL

case "$1" in
'start')
#
# Sybase server startup.
#
su sybase -c "$INSTALL/startserver -f $INSTALL/RUN_FOO -f $INSTALL/RUN_FOO_BACKUP &"
;;

'stop')
#
# Sybase server shutdown.
#
$ISQL -S FOO -U sa -P password > /dev/console 2>&1 <<-'END'
shutdown SYB_BACKUP
go
shutdown
go
END
;;

*)
#
# Invalid param.
#
echo "Usage: /etc/init.d/sybase { start | stop }"
;;
esac

http://www.pcfixreview.com


Report Offensive Follow Up For Removal

Response Number 2
Name: KirstyN
Date: October 1, 2008 at 18:10:26 Pacific
Reply:

This might also help:

Before you begin, make sure the table is not in use. Then use the isql utility to perform these manual steps, entering go after each command:

1.

Turn on support for making changes to tables:

sp_configure "allow updates to system tables", 1

2.

Enter these commands to make the database writable:

use database-name

3.

Enter the following commands and write down the ID numbers:
*

For the database ID:

select db_id database-name

*

For the ID of the corrupt table:

select id from sysobjects where name = bad-table-name

*

For the table's index IDs:

select indid from sysindexes where id = bad-table-id

4.

Optional but highly recommended step. Mark the start of a user-defined transaction:

begin tran

5.

Delete all system catalog information for the object, including any object and procedure dependencies by creating and using all of this short script:

declare @obj int

select @obj = id from sysobjects where name = bad-table-name

delete syscolumns where id = @obj

delete sysindexes where id = @obj

delete sysobjects where id in (select constrid from sysconstraints where
tableid = @obj)

delete sysdepends where depid = @obj

delete syskeys where id = @obj

delete syskeys where depid = @obj

delete sysprotects where id = @obj

delete sysconstraints where tableid = @obj

delete sysreferences where tableid = @obj

delete sysattributes where object = @obj

delete syspartitions where id = @obj

Note:

If you make a mistake, cancel the transaction using the rollback command; and then correct and submit the script again.
6.

Mark the end of the transaction:

commit tran

7.

Prepare to run dbcc, using the undocumented and unsupported option extentzap. Make the database read-only by submitting each of the following commands:

use master

sp_dboption database-name, read only, true

use database-name

checkpoint

WARNING!

When you execute dbcc extentzap, it deletes all extents for a given object ID and indid. The only way to recover the data is to use a database backup.
8.

Run dbcc extentzap twice for each index. Remember that if the table has a clustered index, you also need to delete extents on index 0, even though that indid has no sysindexes entry. Using the following syntax, be very careful to use the correct object ID; that is, the object ID of the bad table:

dbcc traceon(3604)

/* to see the errors */

dbcc extentzap (database-id, object-id, index-id, 0)

dbcc extentzap (database-id, object-id, index-id, 1)

9.

Clean up using the following commands:

use master

sp_dboption database-name, read only, false

sp_configure allow, 0

reconfigure

use database-name

checkpoint

http://www.pcfixreview.com


Report Offensive Follow Up For Removal







Use following form to reply to current message:

Not Logged In!

You will not be able to post.

Register | Login
   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Script to check database status 

Comments:



Results for: Script to check database status

Convert Excel to Access database
    Summary: I am looking for help and info to convert an Excel Spreadsheet to an Access Database (MDB) Any help or guidance would be great! Thanks in advance for the help ...
www.computing.net/answers/dbase/convert-excel-to-access-database/39.html

Sync online database to offline dat
    Summary: I would like to Synchronize an online database to offline database. we use a online shopping cart that runs on sql and we use a software to track sales which also runs on sql. I would like to write a ...
www.computing.net/answers/dbase/sync-online-database-to-offline-dat/155.html

saving information to database
    Summary: I believe that it will take a lot of work. I did a google on "window close event" and found the following page: http://www.dotnetjunkies.com/WebLog... Basically it says there is no "window close even...
www.computing.net/answers/dbase/saving-information-to-database-/214.html






Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History






Data Recovery Software