Oracle Clone/Copy complete Schema with all dependencies and tablespaces - oracle

Problem to solve, let's say that:
We have a new clean install of Oracle 11G R2.
We want to copy/clone a Schema from another one with all needed Tablespaces and dependencies.
We want to minimize all manual recreation of tablespaces and so on, also some Packages may or may not have dependencies out of that schema - so we need to check for that too.
What would be the best way to do that. Software options are welcomed too, please describe the procedure if you know with what application and how to be done.
Example: Oracle Sql Developer, such and such steps, at least in brief.
if you know how to make it work with 'EXPDP ... include=tablespace' can you please write the full command for exporting a selected Schema including the Tablespaces and all 'packages/function/trigers...etc' and how to IMPDP that after that.
Thank you very much community.

Remap_schema (+ remap_tablespace if you want it) is what you are looking for:
expdp schema1/pwd DIRECTORY=dump_dir DUMPFILE=schema1.dmp \
LOGFILE=schema1_exp.log SCHEMAS=schema1
impdp schema2/pwd2 DIRECTORY=dump_dir DUMPFILE=schema1.dmp \
LOGFILE=schema1_imp.log REMAP_SCHEMA=schema1:schema2 \
REMAP_TABLESPACE=(schema1_tab1:schema2_tab1,schema1_tab2:schema2_tab2)

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.

Oracle expdp and impdp command?

I want to know the Oracle expdp and impdp command for sys user and scott/tiger user for entire database or a particular table.I will be grateful if you share me the script of expdp and impdp.I also want the script of recovery of a entire database and performance tuning.
There is no such "the" script, as in one single script that does whatever you seem to wan. If you want to know how to use expdp and impdp, then check the documentation - the Utilities manual.
And to address one point, using expdp/impdp as SYS, the manual specifically warns against it, with this quote:
Note:
Do not start Export as SYSDBA, except at the request of Oracle
technical support. SYSDBA is used internally and has specialized
functions; its behavior is not the same as for general users.
And there is no single script for " recovery of a entire database". Recovery of an entire database should actually be done with rman, using backups made by rman, not expdp.
And there is certainly no script for "performance tuning." You are looking for simplistic answers to complex issues. Whole books have been written on performance tuning. Performance tuning depends on identifying the cause of poor performance, and that can come from countless unrelated sources.
Before exporting/importing a dump of the database make sure that you have created a directory and give the permissions to read & write on this for the user that will be used to export/import.
Some basic examples for expdp & impdp:
full database export: expdp scott/tiger#orcl directory=mydir dumpfile=expdp_full_db.dmp logfile=expdp_full_db.log full=YES;
table export: expdp scott/tiger directory=mydir dumpfile=table_exp.dmp logfile=table_exp.log table=test
table import: impdp scott/tiger directory=mydir dumpfile=table_exp.dmp logfile=table_exp.log tables=test
These are just some examples. Expdp and impdp provide a lot more useful options and parameters. More details here (https://oracle-base.com/articles/10g/oracle-data-pump-10g )
But keep in mind that EdStevens is right because there is not a 'script' that can be used to solve any problem, especially performance issues.

Creating a DDL for a baseline for flyway

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 -

clone oracle database without data

I want to clone my existing oracle database structure without data including packages, users, tablespaces etc. I read some methods but they all copied data as well. Is there anyway out in order to do this?
Thanks in advance.
Use SQL Developer > Tools > Database Export..
On "Specify Data" do not include any tables.
Omit packages etc here,
Fine tune your selection here,
My trial export has not finished yet but I expect this will work.
Use Oracle exp.exe utility for export. E.g.
EXP.EXE login/password#TNSNAME file=entire_db.dmp owner=(scott, my_user, user2) rows=n grants=y triggers=y
Only rows=n option in command above make sense for your task.
You can import to target database with imp.exe utility.
Look for detailed option list and definition by running this utilities with help=y option.
BUT tablespaces and users on target databases must be created manually before running import.
There are no standard tablespace cloning tools (including SQL Developer), but some queries exists for generating such cloning scripts.
Examples can be found here and here.
P.S. This question better fits to ServerFault than to StackOverflow ...
You can do it in toad but its not free tool. (Database Tab->Export->Export DDL)
Try Oracle Export command with ROWS=N
exp SCOTT/TIGER ROWS=N TRIGGERS=N
Use SQL Developer, Tools > Database Export.
You will need to specify at least one table in the 'data' option because you cannot choose to NOT export any data. Pick a table that has a small number of rows or create a dummy table without any rows beforehand as a workaround.

oracle express detatach

Hi I am new and I am used to MS SQL Manager's Attach/Detatch functionality to drop a database into a single file so I can move it to other computers/SQL instances. In a nut shell, this is what I want to do.
I have a large Oracle Express database (instance name Zeus) that I need to move onto other Oracle Express instances (brand new installs) and then later I need to keep them updated with Zeus' database.
How do I do this?
I am not understanding how to export the database/schema - user definition/permission, table definitions, and table data.
Thanks guys
I don't believe you can easily do that with Oracle (especially XE edition).
You would usually do an Import/Export. This would give something like :
expdp system/password#XE DUMPFILE=expfull.dmp FULL=y
impdp system/password#XE DUMPFILE=expfull.dmp FULL=y
The expfull.dmp files would be located in a folder named oradata/dpdump in the Oracle XE
installation.
You could also use Transportable Tablespaces as described here and summarized here.
Another method involves 10 steps and would have to be adapted to Oracle XE. I mention it here for reference.

Resources