我正在将数据库从SQL Server移植到PostgreSQL。在PostgreSQL中除了sysobjects
还有别的选择吗?如果是,那么它是什么,如何使用?
我的观点:
create view int_objects_v as
select
io.*, soae."REQ_TYPE_NAME", soae."REQ_TABLE_NAME",
stc1."CODE_DESC" int_type_name, stc2."CODE_DESC" operation_type_name,
s."NAME" target_obj_name
from
int_objects io
left join
req_request_types_v soae on soae."ID" = io."SOURCE_OBJ_ID"
left join
std_type_codes_v stc1 on (stc1."CODE" = io."INT_TYPE"
and stc1."TYPE" = 'intr_type')
left join
std_type_codes_v stc2 on (stc2."CODE" = io."OPERATION_TYPE"
and stc2."TYPE" = 'opr_type')
left join
sysobjects s on (s."ID" = io."TARGET_OBJ_ID")
where
io."ACTIVE_FLAG" = '1';
最佳答案
PostgreSQLsupports the SQL-standard information_schema
。
MSSQL也是,但它也支持sysobjects
,这是information_schema
的旧等价物。
如果您找到了使用information_schema
术语重写查询的方法,那么您就已经准备好了。
也请看这里INFORMATION_SCHEMA vs sysobjects