Subject Re: [firebird-support] Isql "copy" command - anyone know how it works?
Author Norman Dunbar
On 17/01/13 08:59, Norman Dunbar wrote:
> I'm doing some more documentation work on the isql manual. The current
> version mentions a copy command in isql which "copies a table structure
> to another table, or database".

Answering self!

After a brief look at the isql source code. Given my limited experience,
it appears that the copy command is as follows:

SQL> copy from_table to_table [other_database]

All other parameters after the third one are ignored. I cannot see a way
to pass the username and password for this, or the other database, to
the copy command. Nothing I tried appears to work, and the source seems
to show that only the first three parameters are bothered with.

In the file isql.epp I can see the call out to another isql process, in
the COPY_TABLE (starts at line 3524) function at line 3623. (Firebird
2.5 source.)

sprintf(cmd, "isql -q %s -i %s", altdb, ftmp.c_str());
if (system(cmd)) { ... }

Altdb is either the current one, or the other one - if supplied.
Ftmp is simply the name of a temporary file holding the commands
required to copy the table.

It's unfortunate that the temporary file seems to be empty when viewed
and vanishes when the isql process that created it exits.

So there is definitely a problem if isql has had to be renamed. There
doesn't appear to be any way to pass the username and password over to
the child isql process.

I have discovered also, through experiment, that only the equivalent of
CREATE TABLE is actually executed. If the other database is passed,
domains will be created to suit, but no data is copied, no constraints -
other than the primary key, no indices - other than the primary key -
and no triggers.

I should imagine that it the source table depends on a sequence for it's
primary key, that it's pretty unlikely that there will be a new sequence
created in the other db, assuming it is different. (But I can see why!)


Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767