快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

葡京娱乐场真人秀:powerdesigner逆向工程生成PDM时的列注释解决方案



在用powerdesigner逆向工程天生PDM时,列注释(ColumnComment)始终无法天生,历经数小时的探索,找到一个协调的措施,现分享如下。并盼望有高手辅导更好的措施。

邀月应用的是Powerdesigner 15.2,数据库为SQL Server 2008 r2

措施如下:

1、在PowerDesigner界面-File-Reverse Engineer-Database,然后选择一个DBMS,我这里拔取一个由系统默认的SQL Server 2008 DBMS改动而来的SQL_2008_MyDefine。

选好odbc,输入精确的连接串,选择数据库及表。

天生效果:Name为英文,且Comment列为空。

而我们盼望的是Name列为中文,Comment为中文。

查看了下在线赞助,发明在SQL_2008_MyDefine::Script\Objects\Column\SqlListQuery下的Value值如下:

{OWNER, TABLE, S, COLUMN, DTTPCODE, LENGTH, SIZE, PREC, COMPUTE, NOTNULL, IDENTITY, DOMAIN, DEFAULT, ExtIdentitySeedInc, COMMENT, ExtCollation, ExtIdtNotForRepli葡京娱乐场真人秀cation, 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_idc.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.colum葡京娱乐场真人秀n_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

”是可以取到Comment值的,可是天生的PDM为什么Comment列为空呢?考试测验改动该SQL语句,将语句提掏出来,也可以获取结果:

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 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_idc.system_type_id) then (select d.name from 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

sys.columns c

join sys.objects o on (o.object_id = c.object_id)

join sys.schemas u on (u.schema_id = o.schema_id)

join sys.types t on (t.user_type_id = c.system_type_id)

left outer join sys.identity_columns i on (i.object_id = c.object_id and i.column_id = c.column_id)

left outer join sys.default_constraints d on (d.object_id = c.default_object_id)

where

o.type in ('U', 'S', 'V')

and u.name =N'dbo'

and o.name=N'Age'

order by 1, 2, 3

难道Powerdesigner真的这么弱吗?google了一下,看到官方文档:

http://manuals.sybase.com/onlinebooks/group-pd/pdd1100e/advanced/@Generic__BookTextView/1302;hf=0

里面有关于SqlListQuery的解释。

再看看上面的SQL语句,忽然想到,既然可以在SQL查询出结果,那么掉足必然在天生PDM的时刻,

在SQL_2008_MyDefine::Script\Objects\Column中看到这么一段:

The following system variables are available:

(parent table items are also available for columns)

"COLNNAME"// name of the column

"COLNCODE"// code of the column

您可能还会对下面的文章感兴趣: