I am new to the Sybase world. I have a client that is running an application titled GeoGraphix which is a GIS based application of sorts. The GeoGraphix "projects" themselves point at sybase .db databases on the backend. Within the application, there is an option to rebuild the project databases. That option calls the dbunload utility. What I'm attempting to do is to automate that process but am having issues getting dbunload to run within iSql.
Just fyi - when the process does run, it spits out the following to a log of sorts:
SQL Anywhere Unload Utility Version 10.0.1.4051 Connecting and initializing Unloading user and group definitions Unloading table definitions Unloading materialized view definitions Unloading index definitions Unloading functions Unloading view definitions Unloading procedures Unloading triggers Unloading SQL Remote definitions Unloading MobiLink definitions Creating new database Unloading "DBA"."GX_SCHEMA_VERSION" (698 rows) ..... more Unloading of tables ..... and finally at the end: Creating indexes
So the process seems relatively straightforward. Unload the database, reload it, re-create the indexes. Would this be something someone could guide me in automating? Again - I am new to the Sybase world so just looking for help/advice. Not even sure this is the correct forum, if not, apologies - please suggest a more appropriate location.
Thank you very much.
Welcome to SQLAnywhere! There are two approaches to this either go with batch files and the command line utilities, or an isql script using SQL Statements - its really a matter of preference. My preference would be to go for the batch file approach if this is going to be something you are going to do a lot of - it's much easier to parametrise it! It would go something like this (untested):
REM unload the existing database structure and data dbunload -v -c "UID=dba;PWD=*****;DBF=e:\databases\MyOldDatabase.db" -r "C:\Unload\reload.sql" -ii "C:\Unload\unload" REM create a new database with default settings dbinit c:\databases\MyNewDatabase.db REM reload the structure and data from the unload file dbisql -c "UID=dba;PWD=***;DBF=e:\databases\MyNewDatabase.db" READ C:\Unload\reload.sql
Each of these command line utilities has a lot of optional parameters - you need to look at the help for details, so for example you can provide a non-standard dba password for the new database, pre-allocate disk space, use the correct language collation etc etc. They also generate exit codes so you could introduce error checking etc.
If the database is of significant size, it is well worth unloading to / reloading from a different (local) disk drive from where the database files are - the speed difference can be huge.
If the database is involved in a replication scheme you need to look at this help topic.
If you want to build the rebuild option into an application, you could go down the road of using the dbtools library.