Hello.

We have a database driven system that serves multiple clients. We have a
single database for this purpose. The data(rows) in some of the tables are
specific to individual clients. In all such tables, we have a field
FLD_CLIENT_ID whose value depicts the client to whom that row of information
corresponds to. All other tables in the system, are agnostic to client
information; but are required for the system to function as a whole.

I would want to take seperate backups for individual clients. I try to use
mysqldump to generate a dump file by filtering on the FLD_CLIENT_ID column.
However, since not all tables contain the FLD_CLIENT_ID column, mysqldump
fails.

I use mysqldump from the commandline as
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
?>mysqldump --single-transaction -u root clientdb --where="FLD_CLIENT_ID=1"
> client1_dbbackup.sql
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---

The error that is thrown is
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM
`ACCOUNT` WHERE FLD_CLIENT_ID=1': Unknown column FLD_CLIENT_ID' in 'where
clause' (1054)
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
which means thats the dump can't be created as the table ACCOUNT does not
contain the column FLD_CLIENT_ID.

Is it possible to write the where clause such that it should apply the
FLD_CLIENT_ID filter only if the column exists in the table; and if not,
dump the data anyways.

I am on RHEL - MySQL 4.1.11 - Storage engine INNoDB

Regards,
Rithish.

Reply via email to