V$sqlarea !!
Hi, the following is my question :
1) I know that oracle can keep track each update to the database table like the update command.
e.g. update tableA
set block = 'Y'
where user_id = 'XXX';
But is there any other table i can select the cached SQL other than v$sqlarea and v$sql.
I am able to select update command from 5 days ago using the v$sqlarea. But if i would like to select the SQL command which i executed more than 5 days ago then what should i do ? Is it any parameter that can be set to configure the no of day to store the old sql text in v$sqlarea.
regards,
Kong
Maybe you can look at auditing?
see http://technet.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96521/audit.htm#1108
Similar Messages
-
Possible to find session/user who ran SQL in v$SQLAREA ?
Using this:
select * from v$sqlarea where sql_text like '%2412982%' and sql_text like '%prms%' and module != 'sqlplusw.exe';
I am able to locate a particular instance of a piece of SQL being executed and stored in the library cache.
However, I would really like to know who run it but I never "catch them".
Is there a way?
1* select * from v$sqlarea where sql_text like '%2412982%' and sql_text like '%prms%' and module != 'sqlplusw.exe'
SQL> /
SQL_TEXT
SHARABLE_MEM PERSISTENT_MEM RUNTIME_MEM SORTS VERSION_COUNT LOADED_VERSIONS OPEN_VERSIONS USERS_OPENING FETCHES EXECUTIONS USERS_EXECUTING LOADS FIRST_LOAD_TIME INVALIDATIONS
PARSE_CALLS DISK_READS BUFFER_GETS ROWS_PROCESSED COMMAND_TYPE OPTIMIZER_MODE PARSING_USER_ID PARSING_SCHEMA_ID KEPT_VERSIONS ADDRESS HASH_VALUE
MODULE MODULE_HASH ACTION ACTION_HASH SERIALIZABLE_ABORTS CPU_TIME ELAPSED_TIME I
CHILD_LATCH
select it.company, it.product, p.description, it.transaction_code, ifsapp.km_util_api.conv_to_date_fmt(it.company,to_date(it.transaction_date,'YYYY-MM-DD')) order_date, it.reference, it.wareh
ouse_id warehouse, it.transaction_quantity, it.inventory_unit_of_measure, it.location_aisle, it.location_row, it.location_tier, it.lot_identifier, it.user_profile, it.reference_2, it.referenc
e_3 from ifsapp.prms_inventory_transaction it, ifsapp.prms_product p where it.company=p.company (+) and it.product=p.product (+) and it.company=upper('OKM') and ((it.lot_identifier like upp
er('%2412982%')) or ('' is not null and it.lot_identifier like upper('%%')) or ('' is not null and it.lot_identifier like upper('%%')) or ('' is not null and it.lot_identifier like upper('%%')) or
('' is not null and it.lot_identifier like upper('%%'))) and (('' is null or rtrim(it.product)=upper('')) or (rtrim(it.product)=upper('')) or (rtrim(it.product)=upper('')) or (rtrim(it.product)=
8328 3616 17240 1 1 0 1 1 1 1 0 1 2006-09-28/08:47:09 0
1 134719 134846 0 3 CHOOSE 166 166 0 07000004A8D88FB0 1040757058
Repetitive Distribution.exe 0 0 0 34410000 58880847 N
3I think the SQL listed is wrong, as it only display the SQL created by Oracle whenever the user login, which is:
SELECT DECODE('A','A','1','2') FROM DUAL
And all subsequent SQL issued by the user during the session is not listed.
I am also in the midst of trying of get the user issuing the SQL :-).....MANY THANKS AHEAD.... -
Oracle 8i: full sql text in v$sqlarea
I work with oracle 8i.
is there a v$... that shows the execution plan for a query.
in thev$sqlarea there isn't the full_sqltext column, and I need to know what oracle is doing now.
Message was edited by:
user596611v$sqltext_with_newlines will produce multiple rows per statement.
You'll need an inline view
select t.hash_value, t.sorts, t.executions, t.buffer_gets, t.disk_reads, tn.sql_text
from v$sqlarea t,
(select hash_value,sql_text
from v$sqltext_with_newlines
order by hash_value, piece) tn
where sn.hash_value = t.hash_value
Sybrand Bakker
Senior Oracle DBA -
I've found this page
[http://www.billmagee.co.uk/oracle/sqltune/080_identify.html]
in which is said:
BUFFER_GETS Cumulative total of memory blocks read for this statement
so if I want to see how many blocks a query read per execution I must do ((disk_reads+buffer_gets)/executions) as suggested from the query on the same page.
select sql_text,
executions,
to_char((((disk_reads+buffer_gets)/executions) * 8192)/1048576,
'9,999,999,990.00') as total_gets_per_exec_mb,
to_char((( disk_reads /executions) * 8192)/1048576,
'9,999,999,990.00') as disk_reads_per_exec_mb,
to_char((( buffer_gets /executions) * 8192)/1048576,
'9,999,999,990.00') as buffer_gets_per_exec_mb,
parsing_user_id
from v$sqlarea
where executions > 0
order by 6 descThis is correct?
Buffer gets refers only to the block found in the buffer cache (not loaded from disk) or to the total amount of db block on which the query works (indipendetly if they are found immediately in the buffer cache or must be read from disk) ?
Hope you can help me.
Thanks
Adriano AristarcoYes, the index is appearing on the dba_indexes table, however its state is 'UNUSABLE'.
It looks impdp takes its state from origin metadata, puts into destination, and even is not trying to rebuild it.
Of course, after running ALTER INDEX REBUILD its status was changed to VALID.
So, what's the point impdp tells about its state? It can be hundreds of unusable indexes, why it's not just rebuilding it? -
Statements in v$SQLAREA
I see some sqls in v$sqlarea. But when I query v$session from the hash_Value of v$sqlarea, nothing comes up. Any particular reason why that would be so?
Thank you.
ROkay :) here you go
[1]SELECT * from v$version
BANNER
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production
TNS for HPUX: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
[2] Here is from v$SQLarea
SELECT *
FROM (SELECT Substr(a.sql_text,1,20) sql_text,
Trunc(a.disk_reads/Decode(a.executions,0,1,a.executions)) reads_per_execution,
a.buffer_gets,
a.disk_reads,
a.executions,
a.sorts,
a.address,hash_value,is_obsolete
FROM v$sqlarea a where a.sql_text like 'SELECT%'
order BY 2 DESC)
WHERE rownum <= 10
Results
SQL_TEXT READS_PER_EXECUTION SORTS ADDRESS HASH_VALUE
SELECT /*+ ORDERED U 174265 11 C00000022FFEE2E8 2024820696
SELECT /*+ 168019 3 C00000021BE3E7B0 3675638738
SELECT /*+ 166238 2 C0000002224D1628 4130578616
SELECT /*+ ORDERED U 165886 C000000245E5ADA0 1735771920
[3] Now query v$session with one of the value from #2
Select * from v$session where hash_value = 2024820696
No rows returned
Hope this helps
Thanks,
R -
Hi there,
I created a new user account and granted it dba.
I logged on to this account and I am trying to run select statments on V$SQLAREA, V$SQL, V$SQLTEXT, and V$SQL_PLAN, but I am getting
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
However, I can get into these views with SYSTEM.
I loged into system and tried to grant
grant select on V$SQLTEXT to user_name;
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to change the current username or password
without the appropriate privilege. This error also occurs if
attempting to install a database without the necessary operating
system privileges.
now, I know i'm not trying to change password nor attempting to instal new database.
I am runnning Oracle XE and the views are
OBJECT_NAME OBJECT_TYPE STATUS OWNER STATUS
V$SQL_PLAN SYNONYM VALID PUBLIC VALID
V$SQLAREA SYNONYM VALID PUBLIC VALID
V$SQLTEXT SYNONYM VALID PUBLIC VALID
V$SQL SYNONYM VALID PUBLIC VALID
Where is the problem?
Thanks in advance for any effortHi Jana,
Could you please tell the Oracle Version. I test it and it works. Look:
$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Jue Jul 29 13:57:32 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select granted_role
2 from dba_role_privs
3 where grantee='TJ';
GRANTED_ROLE
CONNECT
RESOURCE
PLUSTRACE
SQL> conn tj/tj
Connected.
SQL> select * from v$sql;
select * from v$sql
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> conn / as sysdba
Connected.
SQL> grant dba to tj;
Grant succeeded.
SQL> conn tj/tj
Connected.
SQL> select count(8) from v$sql;
COUNT(8)
1354
SQL> select count(8) from v$sqlarea;
COUNT(8)
1206
SQL> select count(8) from v$sql_plan;
COUNT(8)
7464
SQL> select count(8) from v$sqltext;
COUNT(8)
11425John -
Clarification in V$SQL and V$sqlarea
Hi Gurus, I have a clarification in V$SQL and V$sqlarea. Is it possible to get the entire set of SQL commands that are executed or run for particular session irrespective of the number of commands that are executed during the session. And can this result be got in a text file.
thanks in advance.Hello,
with execute dbms_system.set_sql_trace_in_session(session_id, serial_id, {True | False}) you can activate SQL tracing for a specific session. SQL Trace will generate a trace file in udump. With TKPROF you can format the output.
If you want to trace your session: ALTER SESSION SET SQL_TRACE = TRUE
regards,
juergen_klinsmann -
V$sqltext & v$sqlarea
I am trying to view the SQL that is being passed to my Oracle 10g server from my .NET app. In a previous post I was told to use the v$sqltext & v$sqlarea views. Using sqlplus from the command line, I am able to produce the 1 line that I believe is the statement I am after. The statement is truncated after 1 line and I am unable to see more. I did try playing with the set command & also tried to find a gui sqlplus so the statement would simply scroll when entered. Is there a gui sqlplus for Oracle 10g? Can anyone offer any advice on how to simply view update, insert & select statements? Any help is appreciated.
Perfect. Downloaded, installed, works wonderful. I can finally see my query. Any ideas why the parameters being passed from .NET are not the actual values being passed into the query?
UPDATE "WHSTSTICKETS" SET "CUSTOMER_ID" = :CUSTOMER_ID, "RECEIVED_BY" = :RECEIVED_BY, "CALL_DATETIME" = :CALL_DATETIME, "AREA_ID" = :AREA_ID, "CLASS_ID" = :CLASS_ID, "STATUS_ID" = :STATUS_ID, "RESOLVE_DUE_DATE" = :RESOLVE_DUE_DATE, "RESOLVE_DATETIME" = :RESOLVE_DATETIME, "RESOLVER_ID" = :RESOLVER_ID, "DETAILS" = :DETAILS, "PRIORITY" = :PRIORITY, "SUBJECT" = :SUBJECT, "EMAIL_CC" = :EMAIL_CC, "ROOT_CAUSE_ID" = :ROOT_CAUSE_ID, "REGION" = :REGION, "EMAIL_CC_1" = :EMAIL_CC_1, "EMAIL_CC_2" = :EMAIL_CC_2, "EMAIL_CC_3" = :EMAIL_CC_3, "EMAIL_CC_4" = :EMAIL_CC_4, "EMAIL_CC_5" = :EMAIL_CC_5, "EMAIL_CC_6" = :EMAIL_CC_6, "EST_HOURS" = :EST_HOURS, "PQR" = :PQR, "PROJECT_ID" = :PROJECT_ID WHERE "WHSTS_ID" = :original_WHSTS_ID -
SQL_FULLTEXT Column of v$sqlarea
All,
What do I need to do so that the full text stored in sql_fulltext column of v$sqlarea is displayed.
At the moment, when I run the following sql:
select SQL_FULLTEXT from v$sqlarea
where sql_id='0n6x4f5kaaymb';
I get the output below:
SQL_FULLTEXT
SELECT INSTALLED_APP_ID, ORIGINATED_DATE, APPLICATION_ID, RECEIVED_DATE, EFFECTI
Thanks in advance
BaffySQL> select SQL_FULLTEXT from v$sqlarea
2 where sql_id='2j0qhrtccbz4u'
3 /
SQL_FULLTEXT
SELECT GA.VALUE FROM SYS.SCHEDULER$_GLOBAL_ATTRIBUTE GA, OBJ$ GO WHERE GA.OBJ# =
SQL> set long 999999999
SQL> select SQL_FULLTEXT from v$sqlarea
2 where sql_id='2j0qhrtccbz4u'
3 /
SQL_FULLTEXT
SELECT GA.VALUE FROM SYS.SCHEDULER$_GLOBAL_ATTRIBUTE GA, OBJ$ GO WHERE GA.OBJ# =
GO.OBJ# AND GO.NAME = 'LOG_HISTORY' -
V$sqlarea : 34769 rows
Hi expert,
I don't know if this is a problem. But how is possible that the v$sqlarea has 34179 records?
SQL> set timing on
SQL> select count(0) from v$sqlarea;
COUNT(0)
34769
Elapsed: 00:01:20.61i'm finding on oracle documentation and
"V$SQLAREA lists statistics on shared SQL area and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution."
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2129.htm
then there are 34000 sql statment in memory?
where I can find some documentation on this view?
many thanks, as usual.
Cheers,
LainDepending on the nature of your application, the size of your SGA, and how well you or your developers use bind variables, the number of statements is perfectly fine or really horrible. Like so many things in Oracle, it depends.
One of our databases has several hundred concurrent users, but they are all using a single application that uses bind variables everywhere and has a fairly limited range of funtionality. It has about 10,000 rows in v$sqlarea. Another database supports a dozen or so concurrent users using many related but different applications most of which have never heard of a bind variable. It has about 60,000 rows, most of them being multiple copies of various sql statements differing only by the literal strings used as predicates.
John -
I have plsql code looking something like that:
if v_state_flag = 'S' and v_next_query = 'Y' then
PKG_COMMON.DEBUG ('GET_ADDRESS_LEVEL_LIST.30, fill o_state_list');
-- kui #postal_flag = 'Y' ja #postalcode on antud, siis lisada klausel
if v_postalcode_flag = 'S' and i_postal_code is not null then
open o_state_list for
select reg.CODE, reg.NAME from V_REGION_LANG reg
where reg.LANGUAGE = PKG_SESSION.LANGUAGE_CODE
and reg.COUNTRY = i_country
and reg.REGION_LEVEL = 'STATE'
and reg.CLOSED_TIME is null
-- kui #postal_flag = 'Y' ja #postalcode on antud, siis lisada klausel
and reg.CODE in (
select r.REGION_CODE1 from REGION r, POSTALCODE p
where r.COUNTRY = p.COUNTRY
and r.CODE = p.REGION_CODE
and p.POSTALCODE = i_postal_code
and p.CLOSED_TIME is null
); View "v$sqlarea" shows this query as:
select * from v$sqlarea where
last_active_time > sysdate - 2
and sql_text like '%REG.CODE, REG.NAME%'
SELECT REG.CODE, REG.NAME FROM V_REGION_LANG REG
WHERE REG.LANGUAGE = PKG_SESSION.LANGUAGE_CODE
AND REG.COUNTRY = :B1 AND REG.REGION_LEVEL = 'STATE' AND REG.CLOSED_TIME IS NULL
;We have " :B1" in query, it stands for plsql parameter "i_country". But we have call to package function "PKG_SESSION.LANGUAGE_CODE" in v$sqlarea query- why wasn't this function replaced with ":B15" for example?
Why plsql parameters are replaced with ":B5" but package functions not?
Does the "PKG_SESSION.LANGUAGE_CODE" in query makes the query slower?PL/SQL variables by default act as Bind Variables when you use them in SQL. But PACKAGE functions or standalone functions are not bind variables.
If you dont want the package name to appear in the SQL area then you need to change the SQL to use a bind variable.
Something like this
if v_state_flag = 'S' and v_next_query = 'Y' then
PKG_COMMON.DEBUG ('GET_ADDRESS_LEVEL_LIST.30, fill o_state_list');
my_value := PKG_SESSION.LANGUAGE_CODE;
-- kui #postal_flag = 'Y' ja #postalcode on antud, siis lisada klausel
if v_postalcode_flag = 'S' and i_postal_code is not null then
open o_state_list for
select reg.CODE, reg.NAME from V_REGION_LANG reg
where reg.LANGUAGE = my_value
and reg.COUNTRY = i_country
and reg.REGION_LEVEL = 'STATE'
and reg.CLOSED_TIME is null
-- kui #postal_flag = 'Y' ja #postalcode on antud, siis lisada klausel
and reg.CODE in (
select r.REGION_CODE1 from REGION r, POSTALCODE p
where r.COUNTRY = p.COUNTRY
and r.CODE = p.REGION_CODE
and p.POSTALCODE = i_postal_code
and p.CLOSED_TIME is null
);By doing this you execute the package function only once. But when you use it in a SQL directly you execute it for every row. -
V$session and v$sqlarea is interpreting in different way
I am using redhad linux 5 version. The db version is oracle11g.
I am trying to run the below shell script on the linux box
export ORACLE_SID=chf01
export ORACLE_HOME=/ora/app/oracle/product/11.1.0/db_1
export WORKDIR=/ora/app/oracle/admin/chf01/scripts
cd $WORKDIR
$ORACLE_HOME/bin/sqlplus scott/tiger@ch01 << EOF
spool sqlcapture.log
INSERT INTO scott.T_SQL_CAPTURE
SELECT MACHINE,
SQL_FULLTEXT
FROM
v$session a,
v$sqlarea b
where
((a.sql_address = b.address
and a.sql_hash_value = b.hash_value )
or ( a.prev_sql_addr = b.address
and a.prev_hash_value = b.hash_value))
commit;
spool off
exit
EOF
ERROR=`grep 'ORA-' sqlcapture.log | wc -l`
if [ "$ERROR" -gt 0 ]
then
cat sqlcapture.log|mailx -s "sqlcapture is failed" \ [email protected]
else
cat sqlcapture.log|mailx -s "sqlcapture is successful" \ [email protected]
fi
exit
here is the spool file content. v$session is interpreted as v a and v$sqlarea is interpreted as v b.
How can i fix this?
SQL> INSERT INTO scott.T_SQL_CAPTURE
2 SELECT MACHINE,
3 SQL_FULLTEXT
4 FROM
5 v a,
6 v b
7 where
8 ((a.sql_address = b.address
9 and a.sql_hash_value = b.hash_value ) 10 or ( a.prev_sql_addr = b.address
11 and a.prev_hash_value = b.hash_value))
13 ;
v b
ERROR at line 6:
ORA-00942: table or view does not exist
SQL> commit;
Commit complete.
SQL> spool offBecause *$* is interpreted by Linux shell. So you need to escape it. I used to escape all $ with \$ but someone in another thread posted a lovely trick. Use this:
$ORACLE_HOME/bin/sqlplus scott/tiger@ch01 << \EOF
. -
V$sql, v$sqlarea and v$sqltext
Hello,
Any idea how to isolate PLSQL objects calls from SQL statement in following views?
v$sql,
v$sqlarea,
v$sqltext
For e.g. I ran following query but it would also include SELECT statements. Whereas I only need PLSQL Calls.
select * from v$sql where upper(sql_text) like 'BEGIN%.%'
Is there any better way?
Thank you in advance for reading this post.
RA select statement can include a pl/sql function call so you cannot exclude selects and search only the begin keyword.
You could join with DBA_OBJECTS, but is not very precise:
select *
from v$sql, dba_objects
where upper(sql_text) like '%'||object_name||'%'
and object_type in ('PACKAGE','PROCEDURE','FUNCTION');Max
http://oracleitalia.wordpress.com -
Real explain plan differs from one in v$sqlarea
I have some more or less complex queries which I catch on runtime by reading v$sqlarea table to find sql with high cost..
but..
I found some highly costed sql, but when I run it through client ti see it's explain plan and execution time, it's much faster with very little cost
why?
am I wrong when I read v$sqlarea?
I'm using Oracle 11g R2This is not at all surprising. Jonathan Lewis and many other have discussed this numerous times both in these forums, in books, in white papers, and in conference presentations.
That said ... you should be looking in gv$sql_plan. -
Could see pending command in v$sqlarea
Hello,
Please see the command and output below :
SQL> select FIRST_LOAD_TIME,SQL_TEXT from v$sqlarea where users_executing > 0;
FIRST_LOAD_TIME SQL_TEXT
2005-11-11/16:45:50 SELECT * FROM ratl_oplog
2005-11-18/14:44:01 select FIRST_LOAD_TIME,SQL_TEXT from v$sqlarea where users_executing > 0
The first entry in the output is pending since 11th Nov...and I think this is reulting in performance problems in my database.
Can somebody suggest some way to solve this issue..??
Thanks, RajeevHello,
first off all have a look at select * from v$session_longops;
To solve this problem alter system kill session.
regards,
juergen_klinsmann
Maybe you are looking for
-
Last line of table shifts to right slightly after export to PDF
Indesign CS4 (6.0.4.578), Windows XP. Last line of some tables shifts very slightly to the right, but only in exported PDFs. See screencap from PDF below. It's not very pronounced, but Xs don't quite line up, and client can see it. When I printed to
-
Ipod not working, tried all suggestions i could find none worked
I have a 20 gb ipod that my mom got from sam's club, there is an hp thing on the back so guess that means it's and hp ipod and not a straight apple ipod which my brother says is bad, it came with a griffen itrip and a griffen powerpod car charger, th
-
Select-option field in dialog programming
hi guys, i need to declare field matnr as select-option range in dialog programming..how can i code it in the module program?
-
Leopard and the "Classic Environment"
I recently installed Leopard on my iMac. I have many very important files "locked" in "Apple File Security" in the O/S 9.2 Classic Environment. I now find out that the "Classic Environment" is no longer supported. I need those files. Can someone tell
-
Help! My photoshop extended crashes every few minutes
Hi -Photoshop Extended CS4 v11.0.02 crashes every few minutes. All other CS4 programs are fine. Any ideas?