查詢Oracle表的約束
select c.CONSTRAINT_name
, c.Table_NAME
, l.COLUMN_NAME
, l.position
,'FK' as type
from sys.ALL_CONSTRAINTS c,sys.ALL_CONS_COLUMNS l
where c.CONSTRAINT_name=l.CONSTRAINT_name
and c.CONSTRAINT_TYPE='R'
and c.owner='SNRC'
and c.Table_NAME not like 'BIN%'
union
select c.CONSTRAINT_name
, c.Table_NAME
, l.COLUMN_NAME
, l.position
, 'PK' as type
from sys.ALL_CONSTRAINTS c,sys.ALL_CONS_COLUMNS l
where c.CONSTRAINT_name=l.CONSTRAINT_name
and c.CONSTRAINT_TYPE='P'
and c.owner='SNRC'
and c.Table_NAME not like 'BIN%';
, c.Table_NAME
, l.COLUMN_NAME
, l.position
,'FK' as type
from sys.ALL_CONSTRAINTS c,sys.ALL_CONS_COLUMNS l
where c.CONSTRAINT_name=l.CONSTRAINT_name
and c.CONSTRAINT_TYPE='R'
and c.owner='SNRC'
and c.Table_NAME not like 'BIN%'
union
select c.CONSTRAINT_name
, c.Table_NAME
, l.COLUMN_NAME
, l.position
, 'PK' as type
from sys.ALL_CONSTRAINTS c,sys.ALL_CONS_COLUMNS l
where c.CONSTRAINT_name=l.CONSTRAINT_name
and c.CONSTRAINT_TYPE='P'
and c.owner='SNRC'
and c.Table_NAME not like 'BIN%';
posted on 2007-06-01 10:46 MingIsMe 閱讀(286) 評論(0) 編輯 收藏 所屬分類: 10 Database