Change Prompt in Sql Plus

Hi
How can I to change Prompt in Sql Plus for to show Enviroment and user ?

this wont work for a pre 10 client.
there you can set the prompt manaualy and this is not dynamic.
make a login.sql
and place the following in the file.
column sqlprompt_col new_value sqlprompt_value
set termout off
define sqlprompt_value='NOT CONNECTED'
select sys_context('userenv','SESSION_USER')||case when sys_context('userenv','ISDBA') = 'TRUE' then ' as sysdba ' end ||'@'||sys_context('userenv','DB_NAME')||sys_context('userenv','INSTANCE') ||'('|| case when instr(sys_context('userenv','HOST'),'.')>1 then substr(sys_context('userenv','HOST'),1,instr(sys_context('userenv','HOST'),'.')-1) else sys_context('userenv','HOST') end ||')' as sqlprompt_col from dual;
set termout on
set sqlprompt '&sqlprompt_value SQL> '
after connecting sqlplus will look for a login.sql file in you present working directory or in its $ORACLE_HOME\sqlplus\admin directory.
if you reconnect is needs to be run again because it is not dynamic.
there is no workaround for pre 10g clients

Similar Messages

  • How to change prompt in sql plus

    i have seen a user. he has changed SQL-PLUS promp
    e.g SQL> to usermech>
    how can i change this.

    use this -
    set sqlprompt little_expertRegards.
    Satyaki De.

  • Changing font in SQL*PLUS

    I need to change Font of SQL*PLUS 3.3 to courier new and font size 8..
    do you have any idea how can I achive this.. I tried changing registry also but it doesnot work.
    I am using Windows 95 machine. My database is Oracle 8i.
    Please help me if you know the answer.

    It changes only at time of editing query .. Actually I wanted to change font of SQLPLUS i.e default font of SQL*PLUS screen should change.

  • Special character when changing password in sql plus

    Hi i'm having a problem with setting password for user's in sql plus. I get a ORA-00922 whenever I try to change a user's password to contain ! in it. See below. Do I have to escape special characters or something or this a bug?
    (Previously I've always used Enterprise Manager for this and can set ! characters for password without issue but we're currently having an issue with it and I need to alter passwords in sql plus while I'm waiting for it to be fixed )
    SQL> alter user lbtest identified by oraclesux!;
    alter user lbtest identified by oraclesux!
    ERROR at line 1:
    ORA-00922: missing or invalid option
    SQL> alter user lbtest identified by oraclesux;
    User altered.
    System and O/S details below:
    O/S = MS Server 2008 Standard Service Pack 1 64 bit
    Oracle 11g Standard Edition (11.1.0.7.0)
    SQL> select * from nls_database_parameters;
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET WE8MSWIN1252
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    PARAMETER VALUE
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 11.1.0.7.0
    20 rows selected.

    Found the answer here, must user double quote for exclamation marks but not other characters like #.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:897930000346894755

  • Making connection to Oracle 9i via SQL Plus - Mark

    Hi,
    I am unable to connect to oracle 9i via dos prompt or SQL Plus.
    I installed the satabase on windows.
    The SID is obiwan. Please help, already browsed similar topics and its not happening.
    Thanks in advance.

    The Listener is the process that is listening for incoming remote connections to the DB(s).
    Database and Listener have Windows services, and services have to be started. Also, from DOS prompt you can do :
    C:\> lsnrctl stat
    to see if the Listener is active : the result should be the list of active DB(s).
    To connect locally to the DB do the following :
    C:\> set ORACLE_SID=obiwan
    C:\> sqlplus "/ as sysdba"
    The result should be something like SQL*Plus: Release 9.2.0.4.0 - Production on Dom Apr 10 16:58:32 2005
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL>If the result is something like : SQL*Plus: Release 9.2.0.4.0 - Production on Dom Apr 10 17:01:29 2005
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to an idle instance.
    SQL>                                                                          then it means that the DB is not up. In this case try :
    SQL> startup
    That way you are connected as sysdba, you can startup and shutdown the DB, create users, and so on. Do not use this connection to create objects (tables, indexes and so on) :
    create an user, using the command "create user" (See [url http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/toc.htm]Sql documentation), and connect as that user, for example
    SQL> conn scott/tiger
    or, at DOS prompt
    C:\> sqlplus scott/tiger
    If you create a TNS alias, as I said before, you can use that as connection string from DOS prompt
    C:\> sqlplus scott/tiger@<TNS alias>
    or using SqlPlus in the Oracle menu.

  • How to change the default directory from within SQL*Plus ?

    Hello,
    I want to change the default directory directly from within SQL*Plus to be able to launch my command files with simple instructions like :
    @my_command.sql
    If I haven't launched SQL*Plus from the directory containing the file my_command.sql, how do I change the default directory to the directory of my command files ?
    I've searched through the Oracle documentation, there's no SET DEFAULTDIR or something like that. When I do a SHOW ALL, there's no variable containing the default directory.
    If you have an idea...
    regards,
    Jérôme.

    Hi Jérôme (J鲴me ?),
    You cannot directly do that, but you can use @@ instead of @ to run subscripts in the same directory as the superscript
    # head /tmp/tl30/xxx/[xyz].sql                    
    ==> /tmp/tl30/xxx/x.sql <==
    prompt call y
    @y
    prompt call z
    @@z
    quit
    ==> /tmp/tl30/xxx/y.sql <==
    prompt i am in y
    ==> /tmp/tl30/xxx/z.sql <==
    prompt i am in z
    # pwd                                             
    /root
    # sqlplus -s scott/tiger@lsc62 @/tmp/tl30/xxx/x.sql
    call y
    SP2-0310: Datei "y.sql" konnte nicht geöffnet werden
    call z
    i am in zKind regards
    Laurent Schneider
    OCM DBA

  • Give SQL*PLUS "password" privilege (to change other's password) to a security role

    Hi,
    If you have DBA privileges on a database, you can also use "password" from SQL*Plus to change another user's password. (When changing another users password, you are not prompted for the users old password.) I would like to grant this function only to a security role rather than to the DBA role.
    Please let me know how to set it up.
    Thanks,
    Seizen

    Hi,
    If you have DBA privileges on a database, you can also use "password" from SQL*Plus to change another user's password. (When changing another users password, you are not prompted for the users old password.) I would like to grant this function only to a security role rather than to the DBA role.
    Please let me know how to set it up.
    Thanks,
    Seizen

  • SQL*Plus Change to File While Being Run

    Anyone,
    Once you execute a file run in SQL*Plus does the entire file get cached by SQLPlus? (i.e. @C:\temp\myfile.sql)
    If I change the file C:\temp\myfile.sql while the session is running (long runing script) will it take effect or not?
    I was able to open the file make a change and save but not sure if SQLPlus will pick up my change when it gets to the point in the script where I made the change. Since it was already running.
    Thanks,
    Miller

    That is a very bad idea to begin with.
    If you made a change at the location that has not yet reached by the SQL*Plus script processing, you could see those changes (again depending upon where and how you do them).
    But in most circumstances, the results will be unpredictable (most likely with error messages) since you cannot control what part of the script the SQL*Plus application is currently executing at the moment you decide to make change to the script.
    For example, I started with this script:
    REM --- Script start ---
    prompt "Waiting ..."
    begin
      dbms_lock.sleep(20) ;
    end ;
    begin
      dbms_output.put_line('This is text') ;
    end ;
    prompt "Finished..."
    REM --- Script end ----And run this within SQL*Plus. While the PL/SQL block was waiting on the sleep call, I removed the first line of the script (the one that starts with the prompt statement) and saved it. Below is the output from this run:
    SQL> @test
    "Waiting ..."
    PL/SQL procedure successfully completed.
    SP2-0734: unknown command beginning "ut_line('T..." - rest of line ignored.
    SP2-0042: unknown command "end " - rest of line ignored.
    PL/SQL procedure successfully completed.
    "Finished..."
    SQL>I would not consider this as a successful completion of the script.
    At this point, you are probably playing with probability and taking chances.
    Message was edited by:
    Kamal Kishore

  • How do i get sql plus to start in something other than command prompt?

    I have just installed oracle 11g enterprise addition. I am use to a different type of editor for the sql plus, the one I am use to comes up in a white area and has drop downs for file, tools, spool, help and so on. You can also open notepad with a shortcut. I like this better than command prompt how do i get this?

    I think you mean sqlplusw.exe which is a Windows executable delivered until Oracle 10.2 but no more delivered with Oracle 11g.
    Mayb you can have a look to SQL Developer http://www.oracle.com/technology/software/products/sql/index.html

  • Database not updating with changes from SQL*plus

    I’m having some issues with updating my database. I want to delete some rows in a table that has 323 records, so I run the SQL in SQL*Plus. It tells me that I’ve deleted 222 rows. I then get a count of the number of rows in the table, and it tells me 101. But if I open another SQL*Plus window and get a row count, the original count (323) is what it says. The enterprise manager also tells me 323 records are in that table. Am I missing something here?

    Aimee-
    Until you 'commit' from the session you have issued the 'delete' statement, the other sessions will not be able to see the changes. In other words, the other sessions are getting you a read consistent view of the data.

  • SQL Plus giving SP2-0024: Nothing to change error

    I'm just about to lose my mind.
    I'm running the following in SQL Plus -
    set echo off
    set feedback off
    set linesize 1000
    set sqlprompt ''
    spool c:\TEMP2\App_Eng1.csv replace
    Select A.OBJECTOWNERID||','||B.OBJECTVALUE1 from PSPROJECTITEM B, PSAEAPPLDEFN A
    Where B.PROJECTNAME = 'PRJ732075'
    and B.SOURCESTATUS = 2
    and B.TARGETSTATUS = 1
    and B.OBJECTVALUE2 = ' '
    and B.OBJECTTYPE=33
    and A.AE_APPLID = B.OBJECTVALUE1
    spool off
    and I get the following in return -
    SQL> set echo off
    SQL> set feedback off
    SQL> set linesize 1000
    SQL> set sqlprompt ''
    spool c:\TEMP2\App_Eng1.csv replace
    SP2-0024: Nothing to change.
    Select A.OBJECTOWNERID||','||B.OBJECTVALUE1 from PSPROJECTITEM B, PSAEAPPLDEFN A
    2 Where B.PROJECTNAME = 'PRJ732075'
    3 and B.SOURCESTATUS = 2
    4 and B.TARGETSTATUS = 1
    5 and B.OBJECTVALUE2 = ' '
    6 and B.OBJECTTYPE=33
    7 and A.AE_APPLID = B.OBJECTVALUE1
    8
    spool off
    SP2-0042: unknown command "off" - rest of line ignored.
    Why am I getting these errors?
    Also, when I clear the SQL, rerun the SQL and try to open the App_Eng1.csv file
    I get a window telling me the file is locked. The only way for me to unlock the file is to shutdown the SQL Plus window. Why is this?
    All I am trying to do is to download data from an Oracle table to an Excel spreadsheet. Is there a relatively easy way to do this using SQL Developer code or should I continue to fight with SQL Plus? I'm trying to automate a process so I don't want to use the manual steps like the DTS Import by Excel.
    Any help? Please?

    Thanks for the info. I have another issue. I'm not sure that my Spool Off command is being recognized. Here's the script I'm running -
    set echo off
    set feedback off
    set linesize 1000
    set sqlprompt ''
    SELECT COUNT(*) FROM PSPROJECTITEM;
    spool c:\TEMP2\App_Eng1.csv replace
    Select A.OBJECTOWNERID||','||B.OBJECTVALUE1
    from PSPROJECTITEM B, PSAEAPPLDEFN A
    Where B.PROJECTNAME = 'PRJ732075'
    and B.SOURCESTATUS = 2
    and B.TARGETSTATUS = 1
    and B.OBJECTVALUE2 = ' '
    and B.OBJECTTYPE=33
    and A.AE_APPLID = B.OBJECTVALUE1;
    spool off
    Most of the time the App_Eng1.csv file is telling me that it can't be opened because it's being used by another user, even after I close SQL Plus. I have to physically perform the Spool Off command from the menu. But even then the csv file is blank. Any ideas?

  • How to insert data which contains '&' from SQL*Plus without asking prompt

    Hi,
    I want to insert data in table from SQL*Plus but data value contains '&' as given in below example(insert script).
    There are 10000 rows. When I load from SQL*Plus it is asking for 'value for :P'.
    I dont want to replace '&' with 'and' also there should not be prompt for asking value for :P.
    Example
    Insert into CS_Tracker (TrackId,FeedBack) values ('ARARGE034678','S&P');
    Insert into CS_Tracker (TrackId,FeedBack) values ('ARARGE034676','S&F');
    Insert into CS_Tracker (TrackId,FeedBack) values ('ARARGE034677','A&P');
    Can anyone help me in above issue.
    Thanking in Advance
    Sanjeev

    use
    set define offbeforehand

  • Changing current directory under SQL plus

    Can someone please tell me how I change the current directory under SQL Plus? I'm trying to run the nisetup.sql for XMLNEWS application in Oracle's sample application. I tried @"D:\Downloaded Files\XMLNEWSDIR\nisetup.sql", but, that doesn't work.
    Can anyone help me on this?
    TIA,
    A

    > I do not know of any way to change the default directory once SQL*Plus is running.
    One very late response, but... I have been using the Windows GUI version of SQl Plus (SqlplusW.exe) for years and I change the default directory all the time. Here is how:
    Use the File, Open pull-down menu dialog, and navigate to the folder you want. Then, select one of the files in that directory. I keep a file named 0~A.sql in each folder where I use SQL Plus for that purpose. It contains only comments, something like:
    --SET ECHO ONOnce I open such a file, all the START commands run scripts in that folder.
    Now... since the Windows version of SQL Plus has been deprecated, how in the world can I do the same thing in the DOS command window version of SQL Plus?
    Why in the world doesn't Oracle provide such an obviously useful feature???

  • SQL Plus - Prompt user with: "Would you like to continue?"

    I am running a PL/SQL script using SQL Plus. In the middle of the script, I'd basically like to have the following logic:
    Prompt the user: "Would you like to continue?"
    IF user types 'Y', continue with script (run update statements)
    ELSE IF
    user types 'N', end script
    What is the best way to do this? Thanks!

    I see. So ACCEPT/PROMPT statements are a SQL Plus feature that can only be run BEFORE the DECLARE section?
    ACCEPT i_idnumber PROMPT 'Enter the Prospect ID: '
    ACCEPT i_transnum PROMPT 'Enter the Transnum: '
    ACCEPT i_remark PROMPT 'Enter reason for updating the tribute info: '
    ACCEPT i_hmflag PROMPT 'Enter the tribute type - H or M: '
    ACCEPT i_honor PROMPT 'Enter the Tribute ID: '
    ACCEPT i_hm_remark PROMPT 'Enter a remark for the honor/memorial party: '

  • Change default settings and commands in sql plus

    everytime i execute sql plus I have to change environment commands maually
    (like linesize , wrap ...etc )
    is there is a way to load those defaults not to reexecute them every time I access sql plus
    Anyone have answer ????????

    glogin.sql (%ORACLE_HOME%/sqlplus/admin/glogin.sql) is executed whenever any user starts SQL*Plus on the machine. login.sql (on Windows, defaulted to %ORACLE_HOME%/bin but can be changed by setting the SQLPATH environment variable) is executed for a particular user.
    You change the default linesize, or execute any other SQL*Plus commands, in either of these files.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • Adobe Reader PDF Batch Print

    Question: Is it possible to build a batch printer using the SDK and libraries available with Adobe Reader? Environment: Win XP and Win 7 Client machine install Adobe Reader - required version can be installed VB6 or C# .NET Experience To Date: The Ac

  • I don't receive e-mail notifications

    Hi all there!!! My problem is that from some moment it has stopped sending me notifications both to my e-mail account and Mail app about new events concidering despite I have all the boxes in my Apple Community account Notifications settings checked

  • Adding Calculation Column in Physical layer

    Hi All, I have oppty fact table and product dimension table. I have to create calculation columns credit revenue = ( sum( opptyfact. Revenue where product. productgroup = "credit")) Debit revenue = (sum( opptyfact. Revenue where product. productgroup

  • Newbie in regex... pb with pattern

    Hello, I want to identify each occurence of -> <tr bgcolor="#f7f7f7"> <- in a html code source, this string could be written like this -> <td class="t2" bgcolor="#f7f7f7"> <-... I try the fallowing java code to parse it : Pattern p=Pattern.compile("<

  • Every time i try to log in my apple ID into face time, it tells me that im using an invalid password. But its not!!!

    Every time i try to log in my apple ID into face time, it tells me that im using an invalid password. But its not!!! Please help!