Oracle DDL export - oracle

I am trying to recreate an oracle database in an HSQL database.
this is to enable better unit testing on the local developer systems.
What I need to know is is there anything tool/command I can use in the oracle server/client, that can provide me all the DDL commands for all the objects (tables, synonyms, views etc) in the oracle database.
I am planning to go through the created DDL commands and try to convert these commands into HSQL compatible commands.
Is it possible?
Any suggestions will be welcome.
system information:
Oracle DB: Oracle enterprise server 11g R2.
HSQL DB: hsql 2.2.9

You can use the DBMS_METADATA package along with the data dictionary to generate the DDL for your objects. For example, to generate the DDL for every table in a schema
declare
l_ddl clob;
begin
for t in (select * from user_tables)
loop
l_ddl := dbms_metadata.get_ddl( 'TABLE', t.table_name, USER );
<<do something with l_ddl>>
end loop;
end;
Are you sure that it makes sense to test with a completely different database than what you're really going to deploy to? Even if you translate the DDL to the closest analogue, it seems very likely that you'll get different results for some tests depending on the database you're connected to. Are you sure that you can't install Oracle (potentially Oracle XE if your concerns are primarily about licensing) on the developer's machines?

There are quite a few products that can help.
OpenSource:
http://www.liquibase.org/manual/formatted_sql_changelogs
Commercial with free trial:
http://www.devart.com/dbforge/oracle/schemacompare/new-export-oracle-schema.html
If you use a tool that is generally designed for use with Oracle databases only, you may get quite a lot of non-standard Oracle DDL that needs converting. A cross platform tool is more likely to reduce the work.
When HSQLDB is used in the ORA compatibility mode, it can translate some Oracle types in the DDL to a similar SQL Standard type. So the types may not pose a problem.

One open source inactive project do exact same thing.
http://schemamule.sourceforge.net/index.html

Related

Reading and Updating data of Oracle DB without License

I've got to update the data of an Oracle DB but I'm not the owner and ain't got any Oracle License.
The goal is to explain to my interlocutor how to create a dump from his Oracle DB, to find out how to restore this dump in a DB (a free version of Oracle or something else), update some data in some tables, and then make another dump to send it back to my interlocutor.
So the differents questions I have are:
1- Is it possible to create a dump (maybe in SQL format) without any specifics dependencies to Oracle ?
2- Is there a way to restore this dump in a free lightweight Oracle, or another kind of DB like Postgresql ?
3- Does Oracle, is able to handle any kind of dump et restore it in an Oracle DB or is there any constraints to respect ?
I am very new to Oracle and ain't got, on my personal computer, any possibility to try out the dump/restore by myself; that's why, any help will be appreciated !
1- Is it possible to create a dump (maybe in SQL format) without any specifics dependencies to Oracle ?
Oracle offers Data Pump utilities (export and import) for such purposes. You'd export table (or schema) - result is a ".dmp" file, readable by import utility. You'd then move that file to your own server (see #2 for the rest)
2- Is there a way to restore this dump in a free lightweight Oracle, or another kind of DB like Postgresql ?
On your own server (which could be a laptop; no problem), you'd install a free Oracle Express Edition (XE) database. Currently, the last version is 21c, but some others should still be available in Oracle Technology Network's Download section.
3- Does Oracle, is able to handle any kind of dump et restore it in an Oracle DB or is there any constraints to respect ?
XE database has its limits - from your point of view, the most important is that it can handle up to 12GB of user data. Therefore, if the .dmp file doesn't contain more data than that, you should be able to import it.
Another constraint is the compatibility. Not all exports can be imported into all databases. There's a matrix which shows which versions match; it is available on My Oracle Support site (but you have to have access to it, which you - as you said - don't. Though, generally speaking, "close" Oracle database versions can interchange .dmp files. It would be best if these two database versions match, of course.

How to migrate(convert) database(or just tables) from PostgreSQL to Oracle using only Oracle tools?

Data was sent to our company with PostgreSQL, but we are prohibited to use the tools of PostgreSQL , permitted the use of only Oracle.
How to migrate data from PostgreSQL to Oracle without using a third party application(they are also prohibited)? You can only use the tools of Oracle.
I found this article https://support.oracle.com/knowledge/Oracle%20Database%20Products/2220826_1.html but we don't have Support Identifier
We have one .sql file. It weighs 8 Gigabytes.
It looks like you have so many impediments in your company. Regarding Oracle's SQL Developer Migration Workbench, unfortunately it does not support the migration of PostgreSQL databases. However, the following 3rd-party software tools are available and may assist in migration, but I am afraid you cannot use them as you said that those products are forbidden:
http://www.easyfrom.net/download/?gclid=CNPntY36vsQCFUoqjgodHnsA0w#.VRBHKGPVuRQ
http://www.sqlines.com/postgresql-to-oracle
Other options will only move the data from your Postgresql database to Oracle database, it means that you must have the DDLs of the tables before to run the import:
To move data only, you can generate a flat file of the the
PostgreSQL data and use Oracle SQL*Loader.
Another option to migrate data only is to use Oracle Database
Gateway for ODBC which requires an ODBC driver to connect to the
PostreSQL database, and copy each table over the network using
sqlplus "COPY" or "CREATE TABLE AS SELECT" commands via oracle
database link.
Also, Oracle has discussion forum for migrating non-oracle databases to Oracle.
http://www.oracle.com/technetwork/database/migration/third-party-093040.html
But, if you have only a sql file, you should look at it to see whether you have both DDLs ( create tables and indexes, etc ) and the data itself as insert statements. If so, you need to split it and treat the DDLs to convert the original data types to Oracle datatypes.

Sybase to Oracle table Migration via Migration Wizard offline

How can I create a script of inserts for my sybase to oracle Migration? The Migration wizard only gives me the option to migrate procedures and triggers and such. But there is no select for just tables. When I try to migrate tables offline and move data. the datamove/ folder is empty. I would also want to only migrate specific tables (ones with long identifiers) because i was able to migrate the rest with Copy to Oracle.
I must also note that i do not want to upgrade to an new version of oracle. Currently on ~12.1 so i need to limit the identifiers.
How can I get the offline scripts for table inserts?
You (probably!) don't want INSERTs for offline migration scripts. If you're just running INSERTs, then the online method would probably suffice.
The point of the Offline strategy is to take the data from your Sybase instance to flat, delimited text files (using BCP), which we can THEN use to load back into an Oracle Database using SQLLDR or External Tables which will be EXPONENTIALLY faster than using INSERT scripts.
Take a look at this whitepaper where I go into offline Sybase migrations in detail.
You can consider DCO-based Sybase-to-Oracle replication via the Sybase Rep Server. This way, not only will you have all data moved, but you will also be able to have DML updates propagated online, which will make your system switchable live.

How to download table from Oracle with little server load

I have a Oracle server which is very highly loaded. I want to Select big table with several millions rows of data and download the data using SQL Developer. How I can do this with little performance impact of the production database?
use oracle's export tool for most efficient dump of data from a table.
example
exp user/password tables=mytable query="optional where clause here"
Note you have to have oracle client installed to use it.

Sample database schema for Oracle

Are there any sample databases for Oracle like AdventureWorks for MS SQL? I've searched Oracle site but didn't find any sample database.
The Oracle database installation includes scripts to install sample schemas. Find out more.
Many online examples use the extremely simple EMP and DEPT tables. These tables are not part of the documented schemas listed above. Finding the script for the beloved SCOTT/TIGER schema is harder than you might think. The demobld.sql used to be under the sqlplus sub-directory. Then in 10g (I think) they moved the schema to $ORACLE_HOME/admin/rdbms/scott.sql. In 11gR2 it's moved again, to $ORACLE_HOME/admin/rdbms/utlsampl.sql.
This question can be of some help(?).
Good Databases with sample data
You can run Oracle Live SQL online without Oracle installed. Menu contains:
SQL Worksheet
My Session
Schema. Includes SCOTT, HR, Order Entry (OE) and others.
Quick SQL
My Scripts
Code Library
Contains a search function, scripts, and tutorials.

Resources