Import and replace package & procedure in oracle - oracle

I wanted to import packages and procedures to DB x from another DB y. I used expdp command with include=procedure, package in DB y to export the package and procedure.
In DB x some packages and procedure are already there, so those packages which exist, is showing "already exists", but I need to replace it with this dump as it has some modifications too. Is there any possible way where I can import and replace packages and procedures? It will be a hideous task to manually compile each package.

See this thread for a similar question and a suggestion:
https://dba.stackexchange.com/questions/204968/how-to-replace-and-overwrite-all-existing-objects-in-oracle-with-impdp-for-full
One other option I can think of is to: take export of the source schema and then drop only all the procedures and functions and packages (since you want to replace them anyway) and then run the import which will create them with target code.

Related

Import a table from one user to another Oracle SQL

Is it possible to import a table from one user to another from export dmp file in Oracle?
If yes, how to do it?
I have 2 users: MILLER and DUMMY. MILLER has table Planets. I've made export from MILLER (last.dmp) using Command Prompt, and I want to make import the table into DUMMY user from export file.
I have already tried use information from here but it didn't help me.
I also can add log of command prompt, if necessary.
If you are using the "Original Import" Utility, you should consider that:
The user names must exist before the import operation; otherwise an error is returned.
The IMP_FULL_DATABASE role is required to use this parameter. To import to a different schema than the one that originally contained the object, specify TOUSER.
More information here
Thank you to all of you. Here is the solution:
1)grant IMP_FULL_DATABASE to DUMMY;
2)alter user DUMMY quota 50m on system; (because I had error
IMP-00058: ORACLE error 1950 encountered
ORA-01950: no privileges on tablespace 'SYSTEM'
Import terminated successfully with warnings.)
3)use FROMUSER and TOUSER in command prompt:
C:\>imp dummy#test3 fromuser=miller touser=dummy
Here is the complete process
Exporting:
expdp schema1/password dumpfile=Imported_Table1.dmp directory=DIR tables=sourceTablename;
Importing:
impdp schema2/password DIRECTORY=DIR DUMPFILE=Imported_Table1.dmp
remap_table=schema1.tablename:*destTablename*
remap_schema=schema1:schema2 TABLE_EXISTS_ACTION=append;
destTablename -> Table name in destination schema. If table exists, system import the data otherwise system creates a new table with the data.
Ref: TABLE_EXISTS_ACTION
Addressed Issues:
ORA-39002: invalid operation
ORA-39166: Object schema2.tablename was not found or could not be
exported or imported.
Table "schema2"."tablename" exists. All dependent metadata and data will be skipped due to table_exists_action of skip

How to avoid warning "IMP-00041: Warning: object created with compilation warnings"?

I'm struggling with oracle import utility.
I'm running the script below and getting compilation warning. I have written a script to recompile all the objects after the import but I hate seeing those warnings every time a do a new export and reimport it. Can anyone help me with this issue ?
imp user/CHANGEME/host:8081/dbname fromuser=schemaowner touser=schemauser file=exp_$TODAY.dmp log=imp_$TODAY.log ignore=y
then run scripts like
alter view myview1 compile;
alter view myview2 compile;
alter view myview3 compile;
Is there any attribute or workaround to say please import the parents first then import the views and triggers ect..?

How can I convert an Oracle impdp sqlfile to a PostgreSQL script to import data into PostgreSQL? [duplicate]

I am trying to import the dump file to .sql file using SQLFILE parameter.
I used the command "impdp username/password DIRECTORY=dir DUMPFILE=sample.dmp SQLFILE=sample.sql LOGFILE=sample.log"
I expected this to return a sql file with contents inside the table. But it created a sql file with only DDL queries.
For export I used, "expdp username/password DIRECTORY=dir DUMPFILE=sample.dmp LOGFILE=sample.log FULL=y"
Dump file size is 130 GB. So, I believe the dump has been exported correctly.
Am I missing something in the import command? Is there any other parameter should I use to get the contents?
Thanks in advance!
Your expectation was wrong, I'm afraid. You're asking it to do something it isn't designed for.
The documentation for SQLFILE says:
Purpose
Specifies a file into which all of the SQL DDL that Import would have executed, based on other parameters, is written.
So it will only ever contain DDL.
There isn't a mechanism to turn a .dmp file into a .sql containing insert statements. If you need to put the data into a table, just use the native import.
Individual insert statements - if you could generate them, which SQL Developer will do as a separate task unrelated to your data pump export - would be slower, would have problems with LOBs, and would have to be careful about the order they were run unless integrity constraints were disabled. Data pump takes care of all of that for you.

Does a procedure declared in package requires separate creation outside it?

I am new to creating packages, I have to include a procedure and a function in a package,
I will create a package by declaring its head and body, Body will contains details about procedure and function.
My query is, after package is created, do I need to create that procedure and function again outside? i.e Create and Replace procedure ...and all?
No. You just define the procedure in the package body.
A procedure can either be a stand-alone procedure or it can be part of a package. In real systems, you almost never want to have stand-alone procedures. It virtually always makes sense to put related procedures together into packages to better organize them.

How to delete procedure or function from Package

Suppose you create a package in Oracle 10g and has defined a procedure and a function inside the package.
Now, How to delete a particular procedure or function in the package created, without physically DROPPING the package?? i.e. without using DROP PACKAGE package_name
I was wondering if i could actually perform the above action. Thank you in advance for any suggestions and solutions.
Since all objects in a package are stored as a unit, Oracle won't allow you to modify, drop or add packages or functions without replacing the whole package body.
You can find some discussion on the subject at the Oracle forums.

Resources