Skip to content

Instantly share code, notes, and snippets.

@davidhooey
Last active December 21, 2015 00:48
Show Gist options
  • Save davidhooey/6222961 to your computer and use it in GitHub Desktop.
Save davidhooey/6222961 to your computer and use it in GitHub Desktop.
Oracle PL/SQL script to simulate bind variables, time queries and generate execution plans.
set timing on;
set linesize 120;
--
-- Bind Variable Setup
--
variable Bind1 number;
variable Bind2 varchar2(2000);
exec :Bind1 := 0;
exec :Bind2 := 'Zero';
--
-- Query
--
SELECT
*
FROM
my_table
WHERE
num_column = :Bind1
AND
char_column = :Bind2;
--
-- Query Execution Plan
--
explain plan for
SELECT
*
FROM
my_table
WHERE
num_column = :Bind1
AND
char_column = :Bind2;
select * from table(dbms_xplan.display);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment