上一章讲了对数据库进行逆向工程生成图表操作,可能会遇到无法生成注释的问题:

一、解决PowerDesigner逆向工程没有列注释

1、打开PowerDesigner 15,选择菜单:File→Reverse Engineer→Database 对数据库进行逆向工程生成PDM图表,选择一张表生成:

                 使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题              使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题

生成后双击图表,打开表属性,选择Columns选项,可以看到注释却是空的,而数据库里的表是有注释的

            使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题          使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题

2、选择菜单:Database→Edit Current DBMS,弹出DBMS Properties对话框,选择Script\Objects\Column\SqlListQuery

 使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题使用PowerDesigner 15进行逆向工程生成数据库图表时,列的注释问题

3、可以看到其Value为:

{OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOMAIN, DEFAULT, ExtIdentitySeedInc, COMMENT, ExtCollation, ExtIdtNotForReplication, ExtDeftConstName, Sparse, FileStream, ExtRowGuidCol}

select
    u.name,
    o.name,
    c.column_id,
    c.name,
    case when c.system_type_id in (165, 167, 231) and c.max_length = -1 then t.name + '(Max)' else t.name end,
    c.precision,
    case (c.max_length) when -1 then 0 else case when c.system_type_id in (99, 231, 239) then (c.max_length/2) else (c.max_length) end end as colnA,
    c.scale,
    case(c.is_computed) when 1 then convert(varchar(8000), (select z.definition from [%CATALOG%.]sys.computed_columns z where z.object_id = c.object_id and z.column_id = c.column_id)) else '' end as colnB,
    case(c.is_nullable) when 1 then 'NULL' else 'NOTNULL' end,
    case(c.is_identity) when 1 then 'identity' else '' end,
    case when(c.user_type_id <> c.system_type_id) then (select d.name from [%CATALOG%.]sys.types d where d.user_type_id = c.user_type_id) else '' end as colnC,
    convert(varchar(8000), d.definition),
    case (c.is_identity) when 1 then convert(varchar, i.seed_value) + ', ' + convert(varchar, i.increment_value) else '' end as colnD,
    (select convert(varchar(8000), value) from ::fn_listextendedproperty(NULL, 'user', u.name, 'table', o.name, 'column', c.name) where name = 'MS_Description') as colnE,
    c.collation_name,
    case (i.is_not_for_replication) when 1 then 'true' else 'false' end,
    d.name,
    case(c.is_sparse) when 1 then 'true' else 'false' end,
    case(c.is_filestream) when 1 then 'true' else 'false' end,
    case(c.is_rowguidcol) when 1 then 'true' else 'false' end
from
    [%CATALOG%.]sys.columns      c
    join [%CATALOG%.]sys.objects o on (o.object_id = c.object_id)
    join [%CATALOG%.]sys.schemas u on (u.schema_id = o.schema_id)
    join [%CATALOG%.]sys.types   t on (t.user_type_id = c.system_type_id)
    left outer join [%CATALOG%.]sys.identity_columns i on (i.object_id = c.object_id and i.column_id = c.column_id)
    left outer join [%CATALOG%.]sys.default_constraints d on (d.object_id = c.default_object_id)
where 
   o.type in ('U', 'S', 'V')
[  and u.name = %.q:OWNER%]
[  and o.name=%.q:TABLE%]
order by 1, 2, 3
原脚本

相关文章:

  • 2021-08-01
  • 2022-12-23
  • 2021-05-29
  • 2021-06-06
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2022-12-23
  • 2021-06-17
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
相关资源
相似解决方案