Ask Your Question

Revision history [back]

Actually there's a simple command to do that.

In the menu Tools > SQL...

type:

SCRIPT '<your-path>/<your-db-name>.sql'

Mind the quotes. Also replace <your-path> and <your-db-name> with your path and filename respectively.

On Windows this can look like:

SCRIPT 'c:/my documents/mydb.sql'

On Linux:

SCRIPT '/home/myuser/mydb.sql'

Click on Execute.

You will find the SQL dump of the database in the file <your-path>/<your-db-name>.sql

Here's how the result of the command looks like on a test db I have created:

SET DATABASE COLLATION "Italian"
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE CACHED TABLE "Contatti"("IDAccount" INTEGER NOT NULL PRIMARY KEY,"NomeAccount" VARCHAR(50),"Descrizione" VARCHAR(250))
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 60
SET SCHEMA PUBLIC
INSERT INTO "Contatti" VALUES(0,'prova','prova')
INSERT INTO "Contatti" VALUES(1,'pippo','pippo')
INSERT INTO "Contatti" VALUES(2,'pluto','pluto')

Also, please read these words of wisdom:

The output of the SCRIPT command or statement in the Tools -> SQL ... is a set of commands to create a complete database, including a default user, the database itself, create the tables and fill the tables with data. If you want to import this into a different database engine you have to skip several parts:

SET DATABASE COLLATION "Latin1_General"
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
:
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 60
SET SCHEMA PUBLIC

This are specific commands for the (single user) HDBSQL database and will probably cause funny or hazardous things in other databases. Databases uses their own language flavour to create a database and specify the language and encoding. [...] In general don't execute the complete content of the generated sql file at once in phpmyadmin (or whatever you use to manage the other database), but split it into logical segments (first only the lines with CREATE, ... and finally the lines with INSERT) and better try a single insert statement first before you run them all for the same table.

Source: LibreOffice Forum

Actually there's a simple command to do that.

In the menu Tools > SQL...

type:

SCRIPT '<your-path>/<your-db-name>.sql'

Mind the quotes. Also replace <your-path> and <your-db-name> with your path and filename respectively.

On Windows this can look like:

SCRIPT 'c:/my documents/mydb.sql'

On Linux:

SCRIPT '/home/myuser/mydb.sql'

Click on Execute.

You will find the SQL dump of the database in the file <your-path>/<your-db-name>.sql

Here's how the result of the command looks like on a test db I have created:

SET DATABASE COLLATION "Italian"
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE CACHED TABLE "Contatti"("IDAccount" INTEGER NOT NULL PRIMARY KEY,"NomeAccount" VARCHAR(50),"Descrizione" VARCHAR(250))
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 60
SET SCHEMA PUBLIC
INSERT INTO "Contatti" VALUES(0,'prova','prova')
INSERT INTO "Contatti" VALUES(1,'pippo','pippo')
INSERT INTO "Contatti" VALUES(2,'pluto','pluto')

Also, please read these words of wisdom:

The output of the SCRIPT command or statement in the Tools -> SQL ... is a set of commands to create a complete database, including a default user, the database itself, create the tables and fill the tables with data. If you want to import this into a different database engine you have to skip several parts:

SET DATABASE COLLATION "Latin1_General"
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
:
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 60
SET SCHEMA PUBLIC

This are specific commands for the (single user) HDBSQL database and will probably cause funny or hazardous things in other databases. Databases uses their own language flavour to create a database and specify the language and encoding. [...] In general don't execute the complete content of the generated sql file at once in phpmyadmin (or whatever you use to manage the other database), but split it into logical segments (first only the lines with CREATE, ... and finally the lines with INSERT) and better try a single insert statement first before you run them all for the same table.

Source: LibreOffice OpenOffice Forum

click to hide/show revision 3
Better answer to OP question

Actually there's a simple command to (Update: better read the OP question)

Yes, you can do that.that in two steps:

  1. Exporting your existing DB to a MySQL DB
  2. Connecting databases

== Exporting the DB ==

In the menu Tools > SQL...

type:

SCRIPT '<your-path>/<your-db-name>.sql'

Mind the quotes. Also replace <your-path> and <your-db-name> with your path and filename respectively.

On Windows this can look like:

SCRIPT 'c:/my documents/mydb.sql'

On Linux:

SCRIPT '/home/myuser/mydb.sql'

Click on Execute.

You will find the SQL dump of the database in the file <your-path>/<your-db-name>.sql

Here's how the result of the command looks like on a test db I have created:

SET DATABASE COLLATION "Italian"
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE CACHED TABLE "Contatti"("IDAccount" INTEGER NOT NULL PRIMARY KEY,"NomeAccount" VARCHAR(50),"Descrizione" VARCHAR(250))
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 60
SET SCHEMA PUBLIC
INSERT INTO "Contatti" VALUES(0,'prova','prova')
INSERT INTO "Contatti" VALUES(1,'pippo','pippo')
INSERT INTO "Contatti" VALUES(2,'pluto','pluto')

Also, please read these words of wisdom:

The output of the SCRIPT command or statement in the Tools -> SQL ... is a set of commands to create a complete database, including a default user, the database itself, create the tables and fill the tables with data. If you want to import this into a different database engine you have to skip several parts:

SET DATABASE COLLATION "Latin1_General"
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
:
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 60
SET SCHEMA PUBLIC

This are specific commands for the (single user) HDBSQL database and will probably cause funny or hazardous things in other databases. Databases uses their own language flavour to create a database and specify the language and encoding. [...] In general don't execute the complete content of the generated sql file at once in phpmyadmin (or whatever you use to manage the other database), but split it into logical segments (first only the lines with CREATE, ... and finally the lines with INSERT) and better try a single insert statement first before you run them all for the same table.

Source: OpenOffice Forum

== Connecting DB ==

When you create a new DB the wizard will show you the possibility to connect your Base file to an existing database (using various protocols). The wizard is quite self-explanatory, so you're done. I also think that if you know in advance that you'll be using your DB with MySQL or other DBMSs this is the best option to take since the creation of the DB.

(for Debian/Ubuntu systems and the like) If you are working particularly with MySQL you may find useful to install the package:

sudo apt-get install libreoffice-mysql-connector

which brings in native support for Base-MySQL connections.