Creating a DDL for a baseline for flyway - oracle

I've got an oracle 11 XE database, with 3 schemas in it, that I want to create a DDL file for to make a baseline script to use with flyway.
I've tried to export just the DDL of all 3 schemas, but the resulting sql doesn't include the creation of the users, or the creation of the tablespaces. It just starts off with sql to create tables, which will not work as the users or the tablespaces don't exist.
Is there any way to do this with sql-developer or am I using the wrong tool for the job here?
I'm thinking I may need to include all the SYSTEM objects in the DDL, but no idea how importing that into a running oracle instance will work.
Any tips or hints I'd be grateful for, I'm starting to think this plan just isn't possible. :-(
Thanks
Matt

when we generate the ddl for a schema, we grab the schema objects, not the definition of the user that owns the schema, nor the tablespaces used IN the schema
you can still get those though, just open the DBA Panel -

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 copy an Oracle DB Schema in Oracle Cloud

I'd like to copy a schema to a newly created one in Oracle Database, in Oracle Cloud.
As far as I know, these databases are managed ones, so I can't run expdb / impdb on them.
Any other idea how to copy (~clone) an entire schema?
Thanks,
As #dmitry shared above-
1.Extract DDL stackoverflow.com/questions/10886450/…. 2.Extract data csv github.com/dmitrydemin1973/powershell-oracle/blob/master/… or insert sql. 3. Create tables in cloud. 4 Load data into tables(sqlloader or sqlplus). 5Create other objects(indexes, procedures, packages,etc ).6 Recompile functions, procedures, packages, views.
Please see #dmitrys response above

Oracle - Export DDL and Data from Schema in correct order

I need to create a copy of DDL and Data from an Oracle 12cR1 schema.
I can't use the SYS or other High Privileges user.
I can only use SQL DEVELOPER using the schema credentials.
The rights I have are:
Create and alter object privileges within the schema (such as CREATE
TABLE).
Insert, read, update and delete data privileges on the tables
within the schema.
Execute privileges on the stored procedures,
functions and packages within the schema.
I can use Oracle SQL Developer or other third party tool.
I have used the "Database Export" functions, but I ahve found no way to get both the DDL and the INSERT queries in the correct order. Some table have dependencies, so I need to respect a logic order for both DDL and Queries.
In my opinion, you should use a tool which is designed to do such a task, and that's Data Pump (Export & Import). It requires you to acquire privileges on a directory which resides on the database server, and that's something that a privileged (SYS) user creates and grants. If there's a DBA there, ask them to provide it for you.
If there's none, you can still use the Original EXP utility which creates a DMP file on your own computer.
The advantage of the export is that Oracle handles everything that seems to bother you.
If I were you, I wouldn't do it manually, there's really no need to do it that way. Apart from the fact that it is time-consuming, you'll have to take care about foreign key constraints, create slow INSERT INTO statements ... shortly, don't do it. Use (Data Pump) export and import.
You can disable all the constraints and triggers first, then insert the data. After data loaded, enable them all.
You can also try to use PL/SQL Developer to export the objects first. This tool exports objects in dependency order. Then export the data, but not sure it exports the data in dependency, you can try if there are disable constraints/triggers option when export.

How to copy a JOB, PROGRAM, SCHEDULE definition to run it in another Oracle 11g DB?

I need to copy some Jobs, Schedules and Programs from an Oracle 11g DB to another one, but when I try to look for the SQL of the Job/Schedule/Program on SQL Developer 4.1.3, the SQL tab shows nothing on Edit mode.
When I open a table and I click on the SQL tab, the SQL for create the table is showed up. I was expecting a similar behavior for a Job/Schedule/Program.
How can I copy a JOB/PROGRAM/SCHEDULE definition to run it in another Oracle 11g DB?
The easiest way for Jobs is to use DBMS_METADATA:
select dbms_metadata.get_ddl('PROCOBJ', job_name)
from user_scheduler_jobs;
I'm not 100% sure about schedules / programs, though.
I think you can also use expdp utility and use include=PROCOBJ. All schedules are objects type PROCOBJ. The you should have all jobs which are owned by schema you are exporting. (If you want DDL you can use impdp with sqlfile= to write dump into SQL file. Or use method suggested by Frank Schmitt)
Unfortunately I think if you use this method or method suggested by Frank Schmitt I think you won't be able to get schedules owned by SYS.

Import and Export Data plus schema using SQLDeveloper 3.0.04

i am newbie to oracle and i like to export database from remote database and import it on local machine. eOn both machines i have oracle 10.2.
I need to know how to export/import schema and data from oracle 10.2 using SQLDeveloper 3.0.0.4.
To export from remote database, i have used export Tool-> Database Export -> export wizard.
and at the end i have got only sql file with DDL and DML statements but somewhere in file it is written
"Cannot render Table DDL for object XXX.TABLE_NAME with DBMS_METADATA attempting internal generator error.
I have ignored previously mentioned message and tried to run those DDL and DML statements but all this ended up with errors.
Is it possible that all this tied with read-only database user? More over, i dont find any table under tables but also tables under other users in SqlDeveloper.
Thanks in advance
As a test, can you select one object in the tree, and navigate to the script panel? SQLDEV also uses DBMS_METADATA to generate those scripts.
Also, as a work-around, try using DataPump to export and import your data. It will be much more efficient for moving around larger schemas.
Your note about not seeing tables under indicates your schema doesn't actually own any tables. You may be working with synonyms that allow you to query objects as if they are in your account. You could be running into a privilege issue, but your error message doesn't indicate that. Error messages often come in bunches, and the very first one is usually the most important.
If you could try using the EXPORT feature say against a very simple schema like SCOTT as a test, this should indicate whether there is a problem with your account settings or with the software.
I'm not sure with SQL Developer 3.0 but with version 3.1 you can follow this:
SQL Developer 3.1 Data Pump Wizards (expdp, impdp)

Resources