Re: Example DB maintenance scripts anyone?
Posted in 1998
Rather than do this by detecting changes in schema or whatever, we have a control table with columns for tablename and version. The version relates to our cvs/bug logging records. We then have a tcl script (our tcl has an embedded sql interface) that can query an existing tables version and apply any necessary updates to the table, such as adding index, loading data, adding a column and populating it, etc. This tcl script is only added to, so can be used to create a completely new database if required, or can be run against existing databases 'without damage'. Works for us... In article <719fpe$qcb@romeo.logica.co.uk> cowhamr@logica.com "Robert Cowham" writes: > Hi all > > I am looking for a few example scripts for ongoing maintenance of a database. > The particular problems which we will need to solve include: > > - adding new tables > - adding columns to tables with data in them and setting default values in the > new columns > > Other related bits and pieces as we support our system over the next few > months and introduce new functions etc. > > The basic stuff is all pretty easy with straight forward SQL, the problem > comes when trying to put some decent error handling around it, and e.g. detect > that a change has already been done and not try again. > > Is Perl the best tool for this? Any other thoughts? How easy is the PerlDB > interface to pick up and use? > > (By the way this is on HPUX10.20 and currently with Informix 7.24) > > Robert > -- =-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-= Andy Lennard andy@kontron.demon.co.uk Kontron Instruments Ltd, Blackmoor Lane, Phone: +44 1923 245991 Croxley Centre, Fax: +44 1923 412211 Watford, Herts, UK. WD1 8XQ =-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=-~-=