UNIX user ID in SQL*PLUS

I want to show the UNIX userID in my SQL*PLUS report's header whosoever will run the script report. Could someone help immediately please?

try with
select username , sid, osuser from v$session;
regards
S.N

Similar Messages

  • User name in sql*plus

    hi there
    I want to know if we can store the user by which one has logged in sql*plus .
    like if I want to store the names , times etc of all the users who logged into oracle using SQL*PLus can I store the name in a varible and insert into a table afterwards..
    thankx
    dg

    There is an environment variable USER that you can use. (select USER from dual).
    null

  • Accepting User input in SQL*Plus

    I am writing a SQL script in SQL*Plus that accepts a value from the user and plugs that value into a variable that exist in several locations outside of the PL/SQL block.
    I am able to do this, yet everytime this variable is encountered, the user is prompted for input. I would like to have the user prompted only once at the beginning and then use that value throughout. This seems like a simple task, yet I cannot get it to work.
    Any help would be greatly appreciated.

    You can use &&<variable_name> and it will define the variable and use it throughout the SQL code.

  • SQLPATH for user profile of SQL*PLUS

    Hi there,
    I am using 9.2 on HPUX. I tried set up my user profile script (login.sql) and place it in a place included in SQLPATH variable. It worked in 8.1.x but not in 9.2
    Is it an identified bug? I have no access to metalink

    Seems to work on my windows environment.
    E:\>set SQLPATH=C:\Temp
    E:\>
    E:\>mkdir C:\Temp\Help
    E:\>
    E:\>echo prompt Help... > C:\Temp\Help\Help.sql
    E:\>
    E:\>sqlplus
    SQL*Plus: Release 9.2.0.3.0 - Production on Thu Sep 25 23:08:40 2003
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Enter user-name: /
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    SQL>
    SQL> @Help\Help.sql
    Help...
    SQL>
    SQL> @Temp\Help\Help.sql
    Help...
    SQL>
    SQL> exit
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    E:\>

  • Accept user input in sql *plus 9.2.0.1.0

    Any body budy can get any idea about my sourcr code?
    I wrote below code in sql *plus
    accept p_hire_date1 date FORMAT 'DD-MON-YYYY' prompt 'ENTER hire date from:'
    accept p_hire_date2 date FORMAT 'DD-MON-YYYY' prompt 'ENTER hire date to:'
    DECLARE
    v_hd1 employees.hire_date%TYPE := TO_DATE(&p_hire_date1);
    v_hd2 employees.hire_date%TYPE := TO_DATE(&p_hire_date2);
    CURSOR emp_cursor IS
    SELECT e.last_name, e.first_name, e.hire_date, e.salary, d.department_name
    FROM employees e, departments d
    WHERE ((e.hire_date>=v_hd1) AND (e.hire_date<=v_hd2)) AND
    (e.department_id=d.department_id)
    ORDER BY e.first_name;
    emp_record emp_cursor%ROWTYPE;
    BEGIN
    DBMS_OUTPUT.ENABLE
    DBMS_OUTPUT.PUT_LINE(RPAD('Name',20) || RPAD('Hire Date',15) || RPAD('Salary',15) || RPAD('Dept. name',15));
    DBMS_OUTPUT.PUT_LINE(RPAD('-',4*15,'-'));
    FOR emp_record IN emp_cursor
    LOOP
    DBMS_OUTPUT.PUT_LINE(RPAD(emp_record.first_name || ' ' || emp_record.last_name,20) || RPAD(TO_CHAR(emp_record.hire_date),15) || RPAD(TO_CHAR(emp_record.salary),15) || RPAD(emp_record.department_name,15) );
    END LOOP;
    END;
    when I execute it I got this error
    SQL> /
    Enter value for p_hire_date2: 23
    accept p_hire_date1 date FORMAT 'DD-MON-YYYY' prompt 'ENTER hire date from:'
    ERROR at line 2:
    ORA-00900: invalid SQL statement
    any Idea?

    Your "accept" statement seems to be correct.
    Please change the declaration of v_hd1 and v_hd2 as below.
    v_hd1 employees.hire_date%TYPE := TO_DATE('&p_hire_date1','DD-MON-YYYY');
    v_hd2 employees.hire_date%TYPE := TO_DATE('&p_hire_date2','DD-MON-YYYY');
    Since p_hire_date1 and p_hire_date2 are date variables enter a valid date of format DD-MON-YYYY. You have entered 23 which is not a valid date.

  • Restricting user from ODBC, SQL PLus, Toad etc

    Hello,
    We would like to restrict user accessing database from anyODBC driver, s/w like Toad or sqlplus. They can only access dataabse through loggin to Application. Is there a way to do it.
    I have been looking into VPD but could not find any info there.
    Thanks
    Suhail

    Don't you need to be able to create a session before you can invoke a secure application role?
    What, exactly, are you trying to prevent. Are you trying to prevent well-meaning users from discovering that they can use Access to "fix" the data in the database when there are problems? Or are you trying to prevent a rogue employee from being able to access the database with anything other than your application?
    If it is the former, something simple like a login trigger that checks the program used to log in would probably work. If it is the latter, I fear you are out of luck. If your application can connect, a moderately competent hacker can access the database rather quickly, particularly if he has access to your application executable.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • 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

  • SQL*PLUS 32 Bit Client needed for Windows 64 Bit

    Hi,
    I have got a 64 Bit Windows OS and an Oracle 11.
    With 32 Bit Applications ( Crystal Reports) I can not run SQL NET Thick, SQL NET Thin and JDBC.
    Oracle 32 Bit Installation is Missing.
    Oracles "Instant Client Downloads for Microsoft Windows (32-bit)" will not do it.
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    What else to use ?
    Thank You
    Martin Sautter

    Martin.Sautter wrote:
    Hi,
    i used:
    instantclient-basic-nt-11.2.0.2.0.zip (32BitClient)
    instantclient-sqlplus-nt-11.2.0.2.0.zip.
    I did not find an "old", "classic" SQL*PLUs client.What does that mean exactly, classic client?
    Did you unzip the ic sqlplus .zip (the one listed) in the same dir as ic basic?
    After dezipping waht than ?
    No installer, nothing ...That's the beauty of Instant Client, just unzip or move a few files, set PATH if needed, and you have client libraries all "installed" and ready.
    >
    You can give advice ?Generally, required lib files are (n Windows) oci.dll, oraociicusN.dll or oraocieiN.dll (N= e.g. 11). Then for Sql*plus add orasqlplusicN.dll and the .exe from ic-sqlplus package.
    C:\Users\Test\Ora-IClite>dir
    Volume in drive C is OS
    Volume Serial Number is 6E8F-186A
    Directory of C:\Users\Test\Ora-IClite
    2011-12-16  09:30    <DIR>          .
    2011-12-16  09:30    <DIR>          ..
    2011-08-31  11:39                38 ldap.ora
    2011-07-30  12:21           683 008 oci.dll
    2011-07-30  12:21        44 153 856 oraociicus11.dll
    2011-07-30  12:21         1 501 696 Orasqlplusic11.dll
    2011-07-30  12:21           869 376 sqlplus.exe
    C:\Users\Test\Ora-IClite>.\sqlplus user@'localhost/xe'
    SQL*Plus: Release 11.2.0.2.0 Production on Fri Dec 16 09:34:13 2011
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter password:Edited by: orafad on Dec 16, 2011 9:35 AM

  • [urgent]sql plus 's user login

    how do i know my sql plus login name and password? when i install...they never ask me to set my own login name and password...

    Hi 489652,
    Which version of oracle you are using?
    Oracle 8i & below sys password is change_on_install & system password is manager
    You can even login as internal with a password oracle.
    if 9i & above you need to provide oracle password for sys & system and no internal login.
    What ever version you use this should work as generic
    01. Login as oracle user in unix box in windows as admin.
    02. export ORACLE_SID=dbname in unix . set ORACLE_SID=dbname in windows
    03. sqlplus "/ as sysdba" you should be loggin as sys ..(as oracle admin)
    Moreover, please remember when you raise this kind of question try to include the version of oracle and OS.
    Cheers,
    kamalesh jk

  • Why so spartan and user unfriendly SQL*Plus?

    Hi,
    I am relatively new to Oracle and therefore I would like to know why SQL*Plus command line utility is so spartan and user unfriendly.
    I am talking about SQL*Plus 10.2.0.1 included in Oracle 10g R2 for Linux x86. On many UNIXes platforms there are readline library and pager utility for output piping. Typical example of user-friendly command line utility is MySQL client. So, my question is:
    why is SQL*Plus binary different (not linked against readline library and doesn't provide a call to pager for output piping)?
    Thanks
    Albert

    I think there is no tool that will do eveything that you want.
    SQL*Plus doesn't format good. Cannot use it for writing packages(sort of). But, it's good for things like 'set autoprint on' to name one. And it's good for tracing.
    SQL Developer: I personally got a bug filed on this one, and since then, lost interest in it.
    PL/SQL Developer: Love this for the way it integrates Visual Sourcesafe, but, it sucks in quering tables with XMLTypes.
    SQL Navigator: Love this for running queries against nested tables. But, this thing sucks at formatting. Somehow , unlike PL/SQL Developer, it semi CHECKS if your code is gonna compile or not BEFORE it formats. I say, dude, I am gonna have to compile the procedure in the database anyway, just format the damn thing.
    Toad: Basically use it to use the session browser, may use it to Kill a session. ( I know I should be using the provided DBMS packages to do that.).
    If you ask me, I can live with SQL*Plus and PL/SQL developer. Pl/SQL Developer because of formatting capabilities and Sourcesafe integration- which is absolutely important for PL/SQL too).
    My two cents.
    Rahul.

  • Restricting the user to operate DML's from SQL PLUS Environment

    how to Restrict the user to operate DML statements from SQL PLUS Environment.

    Once you restrict SCOTT user to not be able to do an INSERT command, the SQL*Plus returns an error for user SCOTT when he tries to execute an INSERT statement.
    Note however, that this is enforced by SQL*Plus, not the database!
    Look into the use of product_user_profile from Oracle documentation for more information.
    SQL> insert into product_user_profile values('SQL*Plus', 'SCOTT', 'INSERT', NULL, NULL, 'DISABLED', NULL, NULL) ;
    1 row created.
    SQL> commit ;
    Commit complete.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    SQL>
    SQL> connect scott
    Enter password:
    Connected.
    SQL>
    SQL> insert into emp select * from emp ;
    SP2-0544: invalid command: insert
    SQL>
    SQL>

  • Unix Environment variable for connect string in SQL*Plus

    I am using some environment variables to connect to a sql*plus session in unix.
    they are exported as part of a file which contains the following and gets executed through the .profile.
    export db_username=xxx
    export db_password=xxx
    export db_name=xxx
    i have created a file abc.sql which contains the following
    connect $db_username/$db_password@$db_name
    Now, I have a shell script which uses this file inside it to connect to a sql*plus session and execute some queries.
    The contents of the shell script :
    API_CONNECT_SQL=abc.sql
    sqlplus /nolog << THEEND
    WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
    WHENEVER OSERROR EXIT FAILURE ROLLBACK
    set timing on
    @${API_CONNECT_SQL}
    ---- do something
    EXIT
    THEEND
    Now, the sql*plus session is able to get db_username and db_password, but not the db_name. It says "TNS service name not found".
    If I hardcode some database name in place of db_name, it connects properly.
    Please let me know the problem and solution as well.
    Any help appreciated.
    thanks,
    Vijay

    for me this one works
    # =========================================
    # begin of script
    # =========================================
    export db_username=alpha
    export db_password=bravo
    export db_name=charly
    echo "connect $db_username/$db_password@$db_name" > xxx.sql
    API_CONNECT_SQL=/cfs/dummy1/0/appl/dummy2/rev_04/zzz/tst/xxx.sql
    cat ${API_CONNECT_SQL}
    sqlplus /nolog << THEEND
    spool xxx
    WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
    WHENEVER OSERROR EXIT FAILURE ROLLBACK
    set echo on
    host cat ${API_CONNECT_SQL}
    @${API_CONNECT_SQL}
    select * from dual;
    spool off
    EXIT
    THEEND
    # =========================================
    # end of script
    # =========================================

  • User Name/Password for SQL*Plus

    I installed the Oracle 8i Personal Version in my PC.
    I have been trying to log on to the Oracle SQL*Plus screen, which asks me for the User Name, Password and the Host String.
    Does anybody out there know what I should use here to log on to this screen?
    Thanks in advance.
    Jay
    [email protected]

    Hi,
    Please check old mails and then forward questions.
    User scott/tiger
    DBA system/manager
    SYS sys /change_on_install
    with regards,
    Boby Jose Thekkanath,
    Dharma Computers(P) Ltd.
    Bangalore-India.
    www.dharma.com

  • SQL Plus not work with domain user

    Hey guys,
    have a problem with sql plus in our network. when i started it with the admin it works. but when i started it with a user account, fill in the username, the password and the host and click on the ok button, the window closes and nothing happen. no error no new window, the window simply closes.
    what to do?
    regards

    Hi,
    There might be different reasons behind this.
    Check whether user is created in database or not.
    There might be possibility that, user is in different database.
    SELECT * FROM V$DATABASE; --This will help you to findout database name.
    SELECT * FROM DBA_USERS WHERE USERNAME = 'HR';  --HR is user present on database. If your user is present in database then user might not have connect privilege.
    GRANT CONNECT , RESOURCE TO HR; --HR is user. To execute this command, login as sys You can also try to login with command prompt.
    sqlplus user/password@host

  • Sql  plus not accepting user id and password as scott, tiger resp

    Hi, this is mihir shah
    I have just installed oracle9i
    And I have a problem in opening the sql plus. It asks for user id and pass but when entered scott, tiger it always gives a tns error.
    Could you tell me how to make a database & how to log on & how to make a new user id and password

    It seem that you have problem with network connectivity to you database.
    Check the listener status and the configuration of the files: tnsnames.ora & listener.ora
    In all cases you must specified the error.
    Bye, Aron

Maybe you are looking for