• 解决PowerDesigner反向工程没有注释(SQLSERVER )


    没有表的注释: 

    在PD的 Tools-->Resources-->DBMS-->SQL Server 2005打开DBMS属性窗口,在General选项卡中选择Microsoft SQL Server 2005-->Script-->Objects-->Table-->SQLlistquery的value修改其中的内容为:

    {OWNER, TABLE, TABLE_TYPE, COMMENT,TNAME}
    
    select
       u.name,
       o.name,
       case (o.type) when 'S' then 'SYSTEM TABLE' else 'TABLE' end,
       convert(varchar(8000),isnull(f.value,o.name)),
       (select convert(varchar(8000), value) from ::fn_listextendedproperty(NULL, 'user', u.name, 'table', o.name, null, null) where name = 'MS_Description') as coln  
    from
    [%CATALOG%.]sys.sysobjects o
    join [%CATALOG%.]sys.schemas u on (u.schema_id = o.uid)
    left join [%CATALOG%.]sys.extended_properties f on
    (f.major_id=o.id and f.minor_id=0 and f.class=1)
    where
       o.type in ('U', 'S')
    [  and u.name = %.q:OWNER%]
    order by 1, 2

    没有列的注释:     

    在PD的 Tools-->Resources-->DBMS-->SQL Server 2005打开DBMS属性窗口,在General选项卡中选择Microsoft SQL Server 2005-->Script-->Objects-->Column-->SQLlistquery的value修改其中的内容为:

    {OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOMAIN, DEFAULT, ExtIdentitySeedInc, COMMENT,COLNNAME, ExtCollation, ExtIdtNotForReplication, ExtDeftConstName, 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 [%CATALOG%.]sys.extended_properties as ex where ex.major_id = c.object_id and ex.minor_id = c.column_id),
        (select convert(varchar(8000), value) from [%CATALOG%.]sys.extended_properties as ex where ex.major_id = c.object_id and ex.minor_id = c.column_id),
        c.collation_name,
        case (i.is_not_for_replication) when 1 then 'true' else 'false' end,
        d.name,
        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
    

    修改完成后,重新生成一次,即可,如果再处理过程中,那是语法未整理好,请一定注意语法问题。

  • 相关阅读:
    python 面向对象之路(1) 类和对象 三大特性 封装 继承 多态
    python 模块之路 异常处理基础 异常处理其他 报错处理
    python 模块之路 序列化 json pickle
    python 模块之路 random模块 时间模块 sys模块 os模块
    python 模块之路 re模块运用
    python -模块之路 正则表达式
    【Unity】粒子特效优化实践
    快速实现Low Poly地形
    【Unity】屏幕空间位置变换到世界空间位置的方法
    Substance Designer 使用手册
  • 原文地址:https://www.cnblogs.com/renzhituteng/p/13321285.html
Copyright © 2020-2023  润新知