替代PostgreSQL中的SQL Server sys对象

时间:2012-10-23 06:18:25

标签: sql-server postgresql

我正在将数据库从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';

1 个答案:

答案 0 :(得分:3)

PostgreSQL supports the SQL-standard information_schema

MSSQL也是如此,但它也支持sysobjects,它等同于information_schema

如果您找到了使用information_schema条款重写查询的方法,那么您就已经完成了设置。

另见INFORMATION_SCHEMA vs sysobjects