• Arun Kumar

Find SQL Id of the Statement You Just Ran

While connected to the database, you might want to know the sql id of the query you just ran (in your own session, not some other session).


Let’s run a sample query

set serveroutput off
Select * from hr.employees;

Now you might want to know the SQL ID of the above command. You must query PREV_SQL_ID column from V$SESSION

select prev_sql_id from v$session where sid=sys_context('userenv','sid');

You can check if the sql id returned above is correct by checking the SQL TEXT associated with the sql id

select sql_id, sql_text from v$sqltext 
where sql_id in ('fxdbrc4jhqn5r');


Recent Posts

See All

How to plan database creation

Database creation process involves several operating system files to work together. You create database only once and later on keep on adding more data files. Before you can simply go ahead and start

Oracle Transportable Tablespace

Assume that you have a schema (IQS) on production server and you want to import the schema into test server. The ideal approach would be to perform entire schema export and import using data pump. Rig

Grant Select on all tables in a schema

I encountered this situation where I wanted to grant SELECT on all the tables owned by one user to another user. There are two simple ways to achieve this: Generate SQL for each table In this method,

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis

Feedback