Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what database is just updated?

Status
Not open for further replies.

babeo

Technical User
Mar 30, 2000
398
CA
Hello,

From a list of tables in a Sybase database, which command or is there any command to show/list for me what table is just updated or current having data inserted into it?

My point is I want to make a quick/short cut on checking if data is going into a database, no matter which table it updates, but at least if there is any table is updated, that means to tell me the data is inserting into the database (well, I means the 'U' type tables, not system tables) - Example: Similar to ls -l a big ftp file and you can see the file size is fifferent with the previous 'ls -l' to confirm that your ftp is still working.

Thanks
 
babeo,

Use the following script which uses sp_spaceused on user tables. Then run it say after few minutes or seconds and use diff -e to see the changes in the output log files. THe problem is that sysobject only shows when table was created (crdate) but not when updated!

Code:
isql -U${USERNAME} -P${PASSWORD} -S${SQL_SERVER_USED} -X -w1000 << ! > ${IN_FILE}
use ${DATABASE}
go
select 'use ${DATABASE} ' + convert(char(1), 0x0A) + 'go'
select 'sp_spaceused ' + name + convert(char(1), 0x0A) + 'go'
from sysobjects where type = &quot;U&quot; order by name
go
exit
!
#
# get rid of 'rows affected' crap from ${IN_FILE}
#
        cat ${IN_FILE} | egrep -i -v 'row' > temp.sql
        mv temp.sql ${IN_FILE}
        #
isql -U${USERNAME} -P${PASSWORD} -S${SQL_SERVER_USED} -X -w1000 < ${IN_FILE} > ${OUT_FILE}
cat ${OUT_FILE} | grep -i kb|sort +1nr +0 |awk '{printf &quot;Table %-25s has %10s rows and is %10s KB\n&quot;,$1,$2,$3}' > temp.sql
        mv temp.sql ${OUT_FILE}
        [ -f ${IN_FILE} ] && rm -f ${IN_FILE}

So remember to run it few times and do a diff -e between out files.

hope this helps
 
Yes, I agree currently that is the only way to find out what has changed in tables until Sybase comes with a better solution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top