Search notes:

Oracle: Force an SQL statement to run for a given amount of time

For testing purposes, it is sometimes desired to have an SQL statement that executes for a given amount of time.
The following statement runs for 5 seconds and a bit:
select max(null) from (
    with n as (select /*+ materialize */ dbms_utility.get_time ow  from dual)
    select
       null
    from
       n connect by n.ow + 500 > dbms_utility.get_time
);
Beware that this statement might throw ORA-30009: Not enough memory for CONNECT BY operation.

See also

Using sysdate in an SQL statement.

Index