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
Related
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.
I have a script generator in .bat file. This .bat generates a sql script and saves it on disk.
Is there any option to open automatically this script in toad? Also if there is already toad application running to open this script in running toad instance?
You can pass the filename to Toad as a command line argument.
Example: >Toad.exe "C:\My Scripts\MyFile.sql"
On the Startup page in Toad's Options there is an option to only allow multiple instances of Toad. If that is unchecked the above call will reuse an open instance of Toad and open your script.
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.
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.
BEGIN
dbms_output.put_line('Welcome to PL/SQL');
END;
/
I have this code in sample.sql file.
How to run sample.sql?
You can run it using SQL*Plus (using your username/password and the name of your instance):
sqlplus username/password#instance # sample.sql
Another way would be to download free SQL Developer from Oracle, open and execute the file there.
Note that the text will not be displayed per default, you need to enable the output before.
Put the following line into your file as first line:
SET SERVEROUTPUT ON