LoginSignup
0
0

More than 3 years have passed since last update.

テーブルの主キー情報を取得する

Posted at
SELECT A.TABLE_NAME, A.POSITION,A.COLUMN_NAME FROM USER_CONS_COLUMNS A 
WHERE EXISTS (SELECT 1 FROM USER_CONSTRAINTS B WHERE TABLE_NAME = A.TABLE_NAME AND CONSTRAINT_NAME = A.CONSTRAINT_NAME AND CONSTRAINT_TYPE = 'P')
AND A.TABLE_NAME IN ( 
'テーブル名1',
'テーブル名2',
'テーブル名3'
)
ORDER BY TABLE_NAME, POSITION

参考URL:http://toronto12.seesaa.net/article/137563650.html

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