Hi Jaden, If you want to do it on programatic way, here are some tips (very briefly) how I did it.
The most simple way to get oracle ddl is using DBMS_METADATA.GET_DDL(obj_type, obj_name, obj_schema) for tables and views, and BMS_METADATA.GET_DEPENDENT_DDL(obj_type, obj_name, obj_schema) for table associated constraints, reference constraints, indices and triggers. Before calling these functions you must strip off from ddl some special oracle attributes (storage, segment, tablespace, etc) using DBMS_METADATA.SET_TRANSFORM_PARAM(). Please see Oracle documentation for details. You can also use DBMS_METADATA.SET_TRANSFORM_PARAM() to strip off reference constraints and constraints from CREATE TABLE statement returned by DBMS_METADATA.GET_DDL() and separate it into extra DDL you can get using BMS_METADATA.GET_DEPENDENT_DDL(). Ddl's you get on this way need some extra editing: there are some statements which does not exist in H2 sintax (ENABLE, DISABLE, NOCHECK, statement MODIFY which have to be replaced with proper ALTER COLUMN, etc ...). It is also recomended to replace column type "DATE" with "DATETIME", because DATE in java does not contain hours / min / sec, and Oracle DATE does. Maybe you'll have to change some view DDL scripts if there is no explicite schema in subordinated table names. Depending on your oracle table description, you may find out some other replacements in ddll scripts are necessary too. When creating H2 tables, it is recomended to create table without prime key, indices and reference constraints, populate tables with data, and then create primary key and indices. This is the fastest way. Reference constraints you must create at end, when all tables are created, because all H2 indices on all tables must be already created at that time (to prevent unecessary index creation - when creating foreign keys, H2 is creating a pair of indices too - if they already exists, they will use existing). Loading tables without indices is very fast in H2, but creating indices after that will take a while on huge tables. This is just a brief information how to do it, but java code doing it is not a trivial program, you will spent some time working on it (maybe too much work just for testing). Best regards, Zvonko -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
