Subject Re: [firebird-support] data dumping
Author Helen Borrie
At 03:36 PM 17/02/2005 +0200, you wrote:

>Hi,
>I did some reading but didn't find a way how to dump only data from a
>firebird database. With isql I could dump only a database structure(DDL)
>with no data(MLD). I found some tools like fbcopy and fbexport but their
>execution terminates immediatly with no errors and with no results :(

FbCopy is for pumping, not dumping.

FbExport works for me.


>It's somehow lame that server comes without tools for data dumping...

Tools for doing most external things are third-party. That's how it comes
about that the server has a footprint of less than 1.5 Mb...

You can use the built-in capabilities to export text if you want, using
external files. Here's a simple example. Create this script in a text
editor and save it (remembering to terminate the script with a carriage
return).

/* script EMPLOYEE_DUMP.SQL */
create table employee_txt external 'l:\data\employee_dump.CSV'
(
EMP_NO CHAR(6), FIRST_NAME CHAR(16),
LAST_NAME CHAR(21), PHONE_EXT CHAR(5),
HIRE_DATE CHAR(25), DEPT_NO CHAR(4),
JOB_CODE CHAR(6), JOB_GRADE CHAR(6),
JOB_COUNTRY CHAR(16), SALARY CHAR(12),
FULLNAME CHAR(37), EOL SMALLINT DEFAULT 2573);
COMMIT;

INSERT INTO EMPLOYEE_TXT
SELECT
CAST(EMP_NO AS CHAR(5))||',',
FIRST_NAME ||',',
LAST_NAME ||',',
COALESCE(PHONE_EXT,'--') ||',',
CAST(HIRE_DATE AS CHAR(24))||',',
DEPT_NO ||',',
JOB_CODE ||',', JOB_GRADE ||',',
JOB_COUNTRY ||',',
CAST(SALARY AS CHAR(11))||',',
FULL_NAME, 2573
FROM EMPLOYEE ORDER BY FULL_NAME;
COMMIT;

Start isql, connecting to the employee.fdb database:

isql c:\program files\firebird\firebird_1_5\examples\employee.fdb -u sysdba
-pas blaaah

SQL>input c:\somepath\employee_dump.sql;
SQL>quit;

Now, open the external file in Excel or a text editor.

>What other tools can you suggest for dumpng/restoring database except
>fbcopy and fbexport?

For dumping - I normally use the Export tool in IB_SQL (free from
www.ibobjects.com).

You don't "restore" from a text file, you restore from a gbak backup.

You might like to look at DBak (www.telesiscomputing.com.au). It's a kind
of dump-and-reconstruct utility.

>Btw, maybe somebody have experienced such strage behavior of the fbcopy too?

Did you try to use it for pumping data table to table?

./hb