Proper Syntax for Oracle IMPDP REMAP_DIRECTORY - oracle

I'm installing Oracle XE 18c on a Windows 10 platform. I'm following the instructions in https://docs.oracle.com/en/database/oracle/oracle-database/18/xeinw/exporting-and-importing-data-oracle-database-xe-11.2-and-18c.html#GUID-6C55327E-2701-426B-A55A-3A576DC78FCE I'm using the section 9.2 - Exporting and Importing Data for Oracle Application Express Users.
I exported the data from my original system, and it completed successfully. I transferred the dump file (DB11G.dmp) to my new system in the folder C:\SS_BACKUPS.
On the original source system the files are located in: C:\oraclexe\app\oracle\oradata\XE
On the new target system (different hardware) the files will be located in: C:\app\product\18.0.0\oradata\XE
On the new target system I executed the following commands in SQLPLUS:
sqlplus SYS AS SYSDBA
SQL> CREATE DIRECTORY BACKUP_DIR AS 'C:\SS_BACKUPS';
SQL> GRANT READ, WRITE ON DIRECTORY BACKUP_DIR TO SYSTEM;
SQL> GRANT IMP_FULL_DATABASE to SYSTEM;
Then from a privileged DOS prompt I ran the command:
impdp system/(my_password)#localhost/xepdb1 full=Y REMAP_DIRECTORY='C:\oraclexe\app\oracle\oradata\XE\':'C:\app\product\18.0.0\oradata\XE\' directory=BACKUP_DIR dumpfile=DB11G.dmp logfile=impdpDB11G.log
When I execute that, I get the error: UDI-00014: invalid value for parameter, 'remap_directory',
I understand the structure of the REMAP_DIRECTORY to be SOURCE:TARGET
Any idea why I'm receiving that error?
Thanks for looking at this.

From the documentation, you must have the DATAPUMP_IMP_FULL_DATABASE role to use the REMAP_DIRECTORY option.
Update 1
According to documentation here:
https://docs.oracle.com/en/database/oracle/oracle-database/18/sutil/datapump-import-utility.html#GUID-5DA84A72-B71C-4491-9DD8-7075D9A4B04F
Depending on your operating system, escape characters can be required
if you use quotation marks when you specify a value for this
parameter. Oracle recommends that you place this parameter in a
parameter file, which can reduce the number of escape characters that
you otherwise would require on the command line.
So, it says try putting the REMAP_DIRECTORY option in a parameter file instead to remove any ambiguities about escaping paths etc.
I think in your case it might be that the colon in the paths perhaps needs escaping or hiding from the shell.

Related

How to Delete command files in Oracle SQL*Plus?

Is it possible to delete file created using "edit" command in SQL*Plus?
You can use the host command to issue a del or rm command, depending on the client operating system.
SQL*Plus has no built-in way of detecting the client operating system, so if you want scripts to be portable, you will have to script a workaround such as examining the value of v$session.program for the current session.

'vi' is not recognized as an internal or external command

When I give edit command in sqlplus, I'm receiving the below error:
I searched on the net and I think, I need to update the environment variable.
Current path value is:
E:\app\sasinghc\product\11.2.0\dbhome_1\bin;D:\app\sasinghc\product\11.2.0\dbhome_1\bin;C:\Program
Files (x86)\RSA SecurID Token Common;C:\Program Files\RSA SecurID
Token
Common;C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files\TortoiseSVN\bin;C:\Program Files (x86)\Microsoft SQL
Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
Server\100\DTS\Binn\
I updated this value to
C:\Windows\System32
but it got even worse, I was unable to open sqlplus, so I rollback the changes.
Now, my sqlplus is working but still I'm able to open afiedt.buf file.
Can you please suggest on this?
ED[IT] command run external editor defined by _EDITOR variable. You can view all variable values with DEF[INE] command. I think you must reset _EDITOR value to some INSTALLED external editor, as Notepad or Wordpad. Use DEF[INE] _EDITOR command, for example: def _editor = notepad
By default a Windows installation of Oracle uses Notepad as the SQL*Plus editor. You seem to have changed that to vi, possibly accidentally.
You can see the current setting with:
SQL> define _editor
which will presumably just show 'vi'. To change it back to Notepad you would do:
SQL> define _editor = "Notepad"
or use the full path. If you have vim installed you can give the full path to that as well, since it doesn't seem to be in your path variable.
You can read more about DEFINE and more specicially the EDITOR value in the SQL*Plus documentation.
You may be picking this change up automatically via a login.sql or glogin.sql profile script - perhaps copied from a Linux/UNIX environment or a PC with Gnu tool installed, etc. If you find and edit that file you can make that change to your preferred editor automatic - whenever SQL*Plus runs it will invoke that login script and set things up for you. It appears it is also currently setting your SQL prompt, so you need to change the file, not replace it completely.
Read more about SQL*Plus configuration via profile scripts.

How to source sql file in windows for Oracle DB

I want to source a sql file located in "C:\Users\Administrator\Desktop\malintha.sql" location. I used following command in sql plus
SQL> #C:\Users\Administrator\Desktop\malintha.sql
But it gives me
Unable to open file error.
How to do this correctly ?
You are doing it correctly but the file either isn't there or you have no permissions.
Double check the path
Ensure you are running the SQLPlus session in a command window with appropriate privs (perhaps Run As Administrator)
Try executing from a regular user directory instead of Administrator
I just tested a SQL file with:
SQL> #C:\users\msmith\desktop\test.sql

Cannot execute .sql with sqlplus (windows)

I have finally connected to sqlplus under windows with command:-
sqlplus -S "dbname/dbpassword#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=)(Port=1521))(CONNECT_DATA=(SID=SID_OF_DB)))"
(Can't connect with configuration file but command line works well for me.)
But I'm not able to execute sql file along with the command.
It is definitely possible to execute .sql file with directive << under linux, but how do I execute in windows?
I'm using sqlplus to generate csv within batch file and importing to mysql. Presently using login.sql as alternate.
You can connect and execute using the '#' followed by your file name as mentioned by Chris. You can use it as follows.
sqlplus -S user/password#SID_OF_DB #oracle.sql
You should be able to run a SQL file by adding #filename onto the end of your command to open sqlplus. If the file is not in your current working directory you will need to include the path. Also if there are any spaces in the name or path then enclose the whole path within double quotes.
Some more info about the command line options can be found here.

Does SQLDeveloper support executing scripts?

I was trying to follow some instructions today, and it starts with the comment
REM In SQLPlus I manually copy in each line and execute it.
That's nice, I don't have SQLPlus, I have SQLDeveloper. The lines that were pasted in were of the type:
#\\server\dir\dir\dir\commandfile1.txt;
COMMIT;
...etc.
It didn't like it when I tried that in a SQL window. I opened up and pasted in the commands by hand, and it wasn't happy with that either. (Did I mention that I'm not so good with this application nor Oracle, but that everyone else was out today?) The files there started with code like:
rem
set echo on
rem
execute procedure_name ('parameter1', 'parameter2');
A co-worker did have SQLPlus, and together we got it resolved. But, is there a way for me to do this with SQLDeveloper, so I'm not stuck if he's out too?
To run scripts in SQL Developer:
#"\Path\Scriptname.sql"
(You only need the quotes if there are any spaces)
You can set a default Path: Tools menu > Preferences > Database > Worksheet > Select default path to look for scripts
I was looking through the help files and found how to do it in SQL Developer Concepts and Usage->Using the SQL Worksheet->Script Runner.
Basically, you have to precede the file name with an #. For example #C:\MyScript\Script.sql.
You can then run a batch of them this way. Note that the command doesn't seem to like spaces in the file path.
For each file you need to run, find it and drop it into SQLDeveloper. Run the script (F5) and then commit (F11). This will work for some scripts, but not all.
SQL Developer these days comes with another tool called sqlcl. This is a bit like SQLPlus but is actually using some bits from SQL Developer to give a compatible command line/scripting type interface.
You would be able to use it to execute sqlplus style commands without fighting the extras of the SQL Developer style GUI which can get confusing.
Look for it under wherever SQL Developer is sitting. If you don't have it there, you can download it and deploy it into your sqldeveloper folder.
you can do it using sqlcl in the same way how you would do it using SQL PLUS, from command line:
sqlcl user/password#host:port:sid #file.sql
file should be in the same directory where sqlcl is.
This solution is the best option if you are trying to execute a lot of instruction on sql file.
This would do it:
begin
procedure_name ('parameter1', 'parameter2');
end;
/

Resources