Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Plus change current directory

Tags:

oracle

sqlplus

How does one change the current directory in SQL Plus under windows.

I am trying to write a script with several "@ filename" commands.

I know that one can open a script with the File --> Open command, which will change the current directory, but I am looking for a way to do this automatically unattended.


Resolution

Based on Plasmer's response, I set the SQLPATH environment variable in Windows, and got something that's good enough for me. I did not try to set it with the HOST command (I doubt that it will work).

Pourquoi Litytestdata's answer is a good one, but will not work for me (the directories are too far apart). And of course Guy's answer that it cannot be done is also correct. I will vote these two up, and accept Plasmer's answer.

like image 601
Andrew Stein Avatar asked Feb 03 '09 21:02

Andrew Stein


People also ask

How do I change the working directory in Oracle?

The cd (change directory) command enables you to move around within the file-system hierarchy. Although your home directory is /export/home/user1 , the cd command returns you to the /home/user1 because home directories are mounted on the /home directory by the automounter.

How do I change directories in SQL Developer?

Go to Tools>Preferences>Database>Export and Browse to the location you want to export to for "Directory".

How do I select a directory in SQL?

List all the directories for which you have the privileges. SELECT * FROM dba_directories a WHERE EXISTS (SELECT 1 FROM all_tab_privs WHERE table_name = a. directory_name AND grantee = USER);

Where is Glogin SQL?

Answer: The glogin. sql file allows you to store global settings for all SQL*Plus queries. The file is localed at $ORACLE_HOME/sqlplus/admin/glogin.


1 Answers

Here is what I do.

Define a variable to help you out:

define dir=C:\MySYSTEM\PTR190\Tests\Test1

@&dir\myTest1.sql

You can't cd in SQL*Plus (you can cd using the host command, but since it is a child process, the setting won't persist in your parent process).

like image 127
Tom Avatar answered Oct 05 '22 21:10

Tom