1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MySQL】プロシージャの内容を確認する方法【information_schema.ROUTINES 】

Posted at

プロシージャの更新日付を見るときによく使うselect文なので、メモっておく:pencil2:
業務で、一時やたらとプロシージャがデグレることがあり、しょっちゅう使ってた・・・。

プロシージャの内容を確認する

もっといろんな情報が(文字コードとかプロシージャの内容とか)見れるけど、たくさんありすぎるので、個人的に普段はこれくらいまでカラムを絞ることが多いです。

select
  ROUTINE_NAME -- プロシージャ名
  , ROUTINE_SCHEMA -- スキーマ名
  , LAST_ALTERED -- 最終更新日時
from information_schema.ROUTINES
where
  ROUTINE_SCHEMA = 'testSchema'       -- スキーマ名を指定する
  and ROUTINE_TYPE = 'PROCEDURE'   -- プロシージャだけを検索する
  and ROUTINE_NAME like 'p_%'      -- プロシージャの名称部分一致
order by ROUTINE_NAME
;

information_schema.ROUTINESとは

プロシージャやファンクションの一覧を保持しているテーブル。
普通のselect文なので、whereもorder byなどが使えるのが便利:pig:

プロシージャの一覧を見るには

SHOW FUNCTION STATUS;

も十分使えるけど、やっぱりwhere句が使える方が捗る:bangbang:

1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?