If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how to delete the record field for multiple table in same database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-22-09, 07:27
shijoe shijoe is offline
Registered User
 
Join Date: Mar 2009
Posts: 13
how to delete the record field for multiple table in same database

We are using sybase data base . Here we have database called yearly_history. This data base contains 100s of tables and each table its having data from 2003. we need to delete 3 yrs of data.
In each table we have field called yearmonth. This will be 200303,200306,200309,200312,200403,200406,200409,2 00412 etc..upto 200903.. we need to delete the data if year month is upto 200603.
I have sample script to delete the record for onemonth..we need to delete the record for atleast 3yrs..pls guide me.



#!/bin/ksh

LOGFILE=$CLOGS/user_record_del_200306.log
uid=operator
srv=phxeslo
pwd=`cat $SYBASE/.operatorpwd`

echo "Started at: "`date` >>$LOGFILE

isql -U$uid -S$srv << EOF >>$LOGFILE
$pwd
use yearly_history
go
print "Started deleting user_record table for the year 200306 "
go
delete user_record where yearmonth=200306
go
EOF

echo "Finished deleting user_record for the year 200306 " >>$LOGFILE
echo "---------------------------------------------------" >>$LOGFILE
date >>$LOGFILE
echo >>$LOGFILE
Reply With Quote
  #2 (permalink)  
Old 04-22-09, 09:11
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Talking Less or equal?

Did you try:
Code:
delete user_record where yearmonth<=200603
go
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On