5
2

More than 1 year has passed since last update.

各SQLで処理中にスリープする方法

Last updated at Posted at 2019-06-27

プログラム側でタイムアウト設定したけど、どうやって試そう…って時用。

SQL Server

-- hh:mm:ss
WAITFOR DELAY '00:00:30';

Oracle

Oracle 12c まで
先にDBMS_LOCK権限を付与

CONN / AS SYSDBA
GRANT EXECUTE ON DBMS_LOCK TO ユーザー名 ;
-- 10秒
DBMS_LOCK.SLEEP(10);

-- 0.5秒
DBMS_LOCK.SLEEP(0.5);

Oracle 18c 以降
権限付与必要なし

-- 10秒
DBMS_SESSION.SLEEP(10);

MySQL

-- 10秒
SELECT SLEEP(10);

PostgreSQL

-- 10秒
SELECT pg_sleep(10);
5
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2