10 Replies Latest reply: Feb 27, 2011 6:41 PM by Aman.... RSS

    sqlplus command line editing

    842872
      I've noticed that if I am in sqlplus (11g) on a Windows box I can bring back my previous SQL commands with the up arrow and edit them just like in mysql.
      This doesnt work in Linux. Is that a difference between the Winders and Linux ports of sqlplus or is there some parameter I can tweak ?

      Thanks in advance
        • 1. Re: sqlplus command line editing
          Thierry H.
          jus use the sqlplus functionalty:

          SQL> ed

          This will always works when you have a default text editor setup on your system.

          the up arrow is system / stting dependant.

          HTH,
          Thierry
          • 2. Re: sqlplus command line editing
            sb92075
            I've noticed that if I am in sqlplus (11g) on a Windows box
            REALLY?
            sqlplus or sqlplusw?
            • 3. Re: sqlplus command line editing
              Aman....
              davep75 wrote:
              I've noticed that if I am in sqlplus (11g) on a Windows box I can bring back my previous SQL commands with the up arrow and edit them just like in mysql.
              This doesnt work in Linux. Is that a difference between the Winders and Linux ports of sqlplus or is there some parameter I can tweak ?

              Thanks in advance
              It's the way it is. If you want to enable the same thing in Linux, you need to use, rlwrap util to do so. Please have a look,
              http://www.oracle-base.com/articles/linux/rlwrap.php

              Aman....
              • 4. Re: sqlplus command line editing
                12cdb
                Use the Unix/Linux vi-editor:
                DEFINE _EDITOR=vi

                Use the Notepad on Windows:
                DEFINE _EDITOR=notepad

                You can add this command in your login.sql or glogin.sql scripts so it executes every time you start sqlplus
                • 5. Re: sqlplus command line editing
                  Aman....
                  Pgoel,

                  First, please reply to the OP and not to me. Second, please read the question a little more closely. The OP wants to have the command line history within sql which is available in the Windows prompt but not in the Linux natively. And for this, having the editor defined or not, will not make any difference and rlwrap would do the job.

                  Aman....
                  • 6. Re: sqlplus command line editing
                    Catch-22
                    Fyi, the information about Readline wrapper is a bit outdated and compiling it, depending on the version of Linux can fail.

                    There is an easier way to install rlwrap using yum. You can install Fedora packages on Enterprise Linux. Check http://fedoraproject.org/wiki/EPEL

                    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
                    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

                    Then simply:
                    # yum install rlwrap
                    then as Oracle user:
                    $ alias sqlplus='rlwrap sqlplus'

                    Edited by: Dude on Feb 26, 2011 5:50 AM
                    • 7. Re: sqlplus command line editing
                      Aman....
                      Wow, thanks for it :) .

                      Regards
                      Aman....
                      • 8. Re: sqlplus command line editing
                        842872
                        Whats the difference between sqlplus and sqlplusw and how could I tell which one I have ?
                        • 9. Re: sqlplus command line editing
                          sb92075
                          Whats the difference between sqlplus and sqlplusw and how could I tell which one I have ?
                          sqlplus is command line (from Command Window)

                          sqlplusw is a GUI via clicking upon an icon.
                          • 10. Re: sqlplus command line editing
                            Aman....
                            davep75 wrote:
                            Whats the difference between sqlplus and sqlplusw and how could I tell which one I have ?
                            You can tell by looking at it since both would be different. SQLPLUS would be a pure command line utility and would be available on all the platforms. But SQLPLUSW is a Windows only tool and you wont find it anywhere else plus you would not find it from 11g onwards in Windows also.

                            Aman....