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
Similar Messages
-
Display column name in sql*plus
Hi,
How to display full column name?
there are n no of tables, i have to query the tables but i want the column name to be displayed fully. for example
SQL> desc control
Name Null? Type
CODE NOT NULL VARCHAR2(255)
LOAD_PERIOD_START_DATETIME DATE
SQL> select code,load_period_start_datetime from control;
CODE
LOAD_PERIOD
AAA
01-AUG-2007
SQL> col load_period_start_datetime format a30
SQL> /
CODE
LOAD_PERIOD_START_DATETIME
AAA
01-AUG-2007
SQL>
As it is only one column i can set with 'col <column_name> format a 30'
if there are n no of coumns from n no tables then how do i get the full column name?
Please help me.
ThanksHi,
you can get all the column's for a TABLE from all_tab_columns this VIEW, why dont you write as script which will generate the commands.
Could you please tell us why do you want to display the compete COLUMN NAME in SQL plus.
Thanks -
How to get the SQL file name in SQL*plus
hi all,
I have created two sql file at C drive as "c:\Createtable.sql" and "c:\Deletetable.sql"
afterwards i open
C:\>sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 30 11:37:10 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: scott/tiger
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> @C:\Createtable.sql'
Table created.
SQL> @'C:\Deletetable.sql'
Table dropped.
SQL>My problem is to get the name of the file as "c:\createtable.sql" and "C:\Deletetable.sql" in sql*plus enviornment.
Thanks & Regards
SinghDear Damorgan,
>>your version number to three decimal places
My Oracle DB Version i have already stated in my previous post is 10.2.0.1.0
Actually my problem is to get the sql files name we run in sqlplus enviornment with @ symbol. like
i have created one sql file in c drive as
"C:\Createtable.sql"
afterwords i have connected to sqlplus as
sql> conn scott/tiger
sql>@c:\createtable.sql
Now i want some query to get the name of the file which is run.
In actual my problem is as
i have suppose 10 or more SQL files in some folder ( sql1.sql, sql2.sql, sql3.sql ....).
i created one file to call all the 10 sql files (main.sql)
i have also one track_table which will keep track that which sql file is runned.
I want some automated script which will insert the record in that track_table....... for that i need the name of sql file which is runned.
Hope this will help you.
Thanks & Regards
Singh -
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 metalinkSeems 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. -
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.
-
hi,
how i can change host name intead of SQL> in sql plus ,
like whenever i connect SQL PLUS scott/tiger@servername, it automatically change prompt SQL> to SERVERNAME>
thanks in advance
Noman ul haqHi,
U can check ur glogin.sql on ur client machine that sets your SQL prompt to SERVERNAME> . So that u can make change in that file , other wise give the following command at ur sql prompt
set sqlprompt SQL>
Cheers,
Vidyadhar -
Agentry - Filter by Current User Name in SQL Step
I'm currently developing an Agentry application that connects to an Oracle back end. I would like to filter by the current user's name in a SQL step that connects to the Oracle database. What's the best way to do this?
Tags edited by: Michael ApplebySee:
http://infocenter.sybase.com/help/index.jsp?docset=/com.sybase.infocenter.pubs.docset-SMP-SDK-3.0.2/doc/html/title.html&docSetID=2021
<<user.name>>
Returns the name of the client user. By default this will be the ID entered by the user to log into the client. This value may be overridden.
<<user.agentryID>>
Returns the user ID entered to log into the Agentry Client. This value cannot be overriden during synchronization. -
I have a login page that asks the user for only the password
(NOT username/password combo). This verifies against my MS SQL
database that contains columns for both "Username" and "Password".
On successful login, the user is directed to my "Survey.asp" page.
My question is, how do I display "Welcome User Name" on my
survey page? Thanks!Pull it from your recordset and display it like this some
where on your
page.
Welcome
<%=(Recordset_Name.Fields.Item("UserName").Value)%>
Dave
"bake01" <[email protected]> wrote in
message
news:ffb0pq$8nt$[email protected]..
> I have a login page that asks the user for only the
password (NOT
> username/password combo). This verifies against my MS
SQL database that
> contains columns for both "Username" and "Password". On
successful login,
the
> user is directed to my "Survey.asp" page.
>
> My question is, how do I display "Welcome User Name" on
my survey page?
> Thanks!
> -
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 -
Dynamically change schema/user name in sql query
I have tables with same name in different schema.
and Suppose I have query like:
select * from myHR.emp;
Now I want to pass variable in place of myHR, may be as follows:
Declare
vSH varchar2(10);
Begin
vSH := 'myHR';
select * from vSH.emp;
End;
But I got error with this query.
I want to pass variable as scheme_name/user.
So, please help me with this.
Thanks in advance.Like said before, it is no different than running any other SQL statement from the client.
All you have to do is run a ALTER SESSION statement immediately after opening the connection:
SQL> alter session set current_schema = your_company_specific_schema_name ;or you can create synonyms under the Oracle user that you use to connect to the database and these synonyms will point to the correct schema.table that needs to be accessed. Then your queries will simply use the synonym as if it were the actual table without caring where the actual table is located.
Justin is faster even considering its a friday.
Message was edited by:
Kamal Kishore -
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
SuhailDon'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 SautterMartin.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 -
How to append timestamp to log file in SQL*Plus ?
Version: 11.2.0.3
Platform : RHEL 5.8 (But I am looking for platform independant solution)
I want to append the timestamp to spooled log file name in SQL*Plus.
The spooled log filename should look like
WMS_APP_23-March-2013.logI tried the following 3 methods found in the google. But none of them worked !
I tried this
col sysdt noprint new_value sysdt_var
SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
spool run_filename_&sysdt_var.Logas suggested in
http://power2build.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/
and this
spool filename with timestamp
col sysdt noprint new_value sysdt
SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
spool run_filename_&sysdt..Logas suggested in
http://powerbuildev.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/
and this
column tm new_value file_time noprint
select to_char(sysdate, 'YYYYMMDD') tm from dual ;
prompt &file_time
spool logfile_id&file_time..logas suggested in
Creating a spool file with date/time appended to file name
None of the above worked in RHEL or MS DOS. Any workaround ?I have tested your suggestions. But I still couldn't append the date to the logfile in RHEL or MS DOS SQL*Plus
Here are the attempts I've made. I am posting how the logfile looked like after every test.
#Attempt1 with two dots (&sysdate..log )
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SYSDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog.&sysdate..log
select 'hello' from dual;
spool off;Log File Name -- > testlog.&sysdate..log
#Attempt2 with single dot (&sysdate.log)
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SYSDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog.&sysdate.log
select 'hello' from dual;
spool off;Log File Name ---> testlog.&sysdate.log
#Attempt3. Replacing first dot with Hyphen (testlog- ) to check if the first dot was causing the issue
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SYSDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog-&sysdate.log
select 'hello' from dual;
spool off;Log Filename: testlog-&sysdate.log
#Attempt4: replacing SYSDATE with SDATE
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog1.&SDATE..log
select 'hello' from dual;
spool off;Log File Name -- > testlog1.&SDATE..log
Maybe you are looking for
-
G'day, how do I send a fax ? Each time I try I receive a 'Print' 'error while printing' message. iMac Mac OS X (10.4.9) 2 GHz intel Core Duo
-
ODBC connectivity for Oracle9i database?
Hi, We are looking at future database platform requirements for our customer service application and starting to look at Oracle 9i. Does anyone know at this early stage whether 9i will support connectivity from an older application which requires ODB
-
can anybody give me a clear cut idea, whether performance of oracle changes or remains same when a oracle package body created with forward declaration of sub programs than with out forward declaration. Ex. create package a as procedure b; procedure
-
How to Define Oracle Server Availability?
Our environment is Oracle E-Business Suite 11.5.4 with Oracle 9.0.1.4 RAC. We would like to define a service level agreement for users. Can you share your opinion how much down time per year is reasonable? Thanks Eric
-
Mail receiving but not sending email.
Mail receives but won't send email. How do I fix this?