Derby database to sql script - derby

Is it possible to get a structure of a derby database so it is saved in a form of an sql script that I can run and it would recreate the database along with the data in it?

The dblook tool (http://db.apache.org/derby/docs/10.8/tools/ctoolsdblook.html) will get the structure of the database and export it as a SQL script.
But it doesn't extract the data.
You could perhaps use the backup and restore utilities, but the format of a Derby backup is not a sql script.
The Apache 'ddlutils' tool can extract and move the data, I believe. See: http://db.apache.org/derby/integrate/db_ddlutils.html
and
http://db.apache.org/ddlutils/

Related

Oracle DB Export does not preserve order or dependencies

I'm trying to export an Oracle DB using Oracle SQL Developer having tables, sequences, view, packages, etc. with dependencies on each other.
When I use Tools -> Database Export and select all DDL options, unfortunately the exported SQL file does not preserve the other that is some DB objects should be created before some other.
Is there a way to make the DB export utility preserve object dependencies/order? Or Is there any other tool do you use for this task?
Thank you
Normally expdp does a pretty good job. Problems arise when there are dependencies on objects/users that are not part of the dump. This is because the counter part, impdp, does not add grants on objects that are not created by impdp. I call that the 'not created by me syndrome' that impdp has.
If you have no external dependencies (external meaning to schema's that are not part of the dump), expdp/impdp do a good job for you. You might not be able to use it if you can not have access to the database server since expdp writes it's files on the database server.
If you happen to have access to a database server that is able to connect to the original database, you could pull the data over into your local database using a database link.

How to use bcp utility with oracle dB or any other better options

I have a csv file which has to be bulk imported to oracle dB. I was working on other sybase dB engine before so I had a sample script which has the environment setup for it. Right now I have to do the process in a oracle dB so what should be the first line I know about the rest other parameters but want to know the path which has to be defined when I write
path/bcp dbtable in data.txt
If anyone could help what should be the path for oracle dB
The primary tools for bulk or flat file loading are:
SQL*Loader
External Tables (and here)
GUI Tools like SQL*Developer
It is much more cumbersome, but if necessary you can roll your own solution with the UTL_FILE PL/SQL package.

Is there a possible way to load a Oracle .dmp file to an SQL Server 2012?

This throws me the below error:
the media family on device is incorrectly formed 3241.
I tried loading the .dmp file as .bak file and restored the db. It did not work.
Only way I know to extract from dmp is to use the "INDEXFILE" parameter for IMP, this will generate a readable SQL script with the DDL and DML.
However often times this script is not 100% usable as it (usually) wraps the statements, so some pre-processing may be required, for example parse the file by each discrete statement (INSERT, CREATE), join each statement into a single line then squirt into the target database. Having said that, you would probably need to pre-process anyway to translate Oracle to SQL server dialogue anyway.
Also, might not be so good for BLOB/binary type data.
The other indirect way to do this would be to create a bridge Oracle database, import the file into there, then use the normal extract and load tools to push the data into SQL server.
A *.dmp file in Oracle is nothing but a backup file. You meant to say restoring a Oracle DB backup file in SQL Server.
AFAIK, the answer is NO. You can't do that. Probably you can check, if there is any third party utility present using which you can perform a DB migration.
The dmp file comes in an Oracle specific format that cannot be parsed/interpreted by anything other than Oracle's imp tool. So, that means you cannot import the dmp file into SQL Server.
Of course there are ways to transfer data from Oracle to SQL Server but which one is optimal depends on your needs, amount of data, number of tables, number of Oracle schemas, datatypes etc etc.

HSQLDB persist in-memory database

I am using an in-memory hsqldb database with a JDBC driver.
Now, I am looking for a way to persist this database for reloading after application reboot. I came up with the following options:
Export .script file with sql command "SCRIPT < path > " (link)
Log all statements to a log file.
Option 2 works, but it seems kind of ugly in my eyes. The script export for option 1 works too, but I seem to be unable to get the .script file back into an in-memory database.
I am thankful for any advice.
The first option is correct.
After you export the database with the SCRIPT <path> statement, you can get it into an in-memory database.
You need to connect to the scripted database with a read-only file: URL
For example if you export the database to d:/dbfiles/mydb.script, you will get the mydb.script file in the named directory. To connect to this database, use file:d:/dbfiles/mydb;files_readonly=true.
There is absolutely no speed difference between the above method and a mem: database.

How to transfer BLOBs to an Oracle database through SQL scripts

I'm developing an application which runs on an Oracle database. I'm now in the process of creating an installation package which will contain some SQL scripts containing the default data that comes with the program.
Some of the tables have BLOB columns which need to contain MS Word documents. I'm not sure how to get these BLOBs into the SQL scripts. I know I could do it through Data Pump, but it is a requirement that all database stuff is included in plain text SQL files.
Does anyone know how to get these BLOBs into an SQL script which the client can just run?
Thanks!
I solved this problem by creating a PHP script that is run as part of the installation process - it loops through all my word documents and inserts them into the database. I would still rather have SQL scripts or something similar but this works for now.

Resources