如何在PowerDesigner裡面去掉統計資訊

來源:互聯網
上載者:User

最新使用PowerDesigner對SQL Server 2000資料庫作反向工程、以比較資料庫和PDM的差異的時候,經常

會從資料庫中Reverse出來一些名稱以“_WA_Sys”開頭的索引,這些索引並不是我們做資料庫設計的時候

加的,而且從企業管理器中也看不到這些索引。
但是,使用“select * from sysindexes where name like '_WA_Sys%'”語句,直接查詢sysindexes系

統表卻能夠查詢出來。
後經查詢相關技術文檔得知,名稱以“_WA_Sys”開頭的索引,其實並不是真正的索引、也不具備索引的

功能,它是SQL Server查詢最佳化工具自動建立的統計資訊(statistics)。
可是我們在PowerDesigner裡面並不需要這些統計資訊,如何才能使PD在Reverse的時候過濾掉這些統計呢


在PowerDesigner裡面依次點擊Tools-Resources-DBMS,開啟“List of DBMS”視窗,從中選擇Microsoft

SQL Server 2000,再點擊視窗上方的第一個按鈕“Property”,現在我們來編輯PD的Reverse行為——
從左側的TreeView中依次展開Script/Objects/Index,點擊SqlListQuery,在右面的Value大編輯框裡我

們可以看到如下SQL語句:
{OWNER ID, TABLE ID, INDEX ID, CLUSTER ID, UNIQUE ID, CIDXLIST ...}

select
   u.name,
   o.name,
   i.name,
   case(i.status & 16) when 16 then 'clustered' else '' end,
   case(i.status &  2) when  2 then 'unique'    else '' end,
   case(k.keyno) when 1 then '' else ', ' end + c.name + case (Indexkey_Property(k.id,

k.indid, k.keyno, 'IsDescending')) when 1 then ' desc' else ' asc' end
from
   sysusers u
      join sysobjects o on (o.uid = u.uid)
      join sysindexes i on (i.id = o.id)
      join sysindexkeys k on (k.id = i.id and k.indid = i.indid)
      join syscolumns c on (c.id = k.id and c.colid = k.colid)
where i.indid between 1 and 254
[  and o.name = %.q:TABLE%]
[  and u.name = %.q:SCHEMA%]
order by
   1, 2, 3, k.keyno

好的,看到了嗎?在where i.indid between 1 and 254的下方加一句:

   and i.name not like '%_WA_Sys%' --過濾掉SQL Server自動建立的統計資訊

就OK了。

加完之後就是現在這個樣子:
{OWNER ID, TABLE ID, INDEX ID, CLUSTER ID, UNIQUE ID, CIDXLIST ...}

select
   u.name,
   o.name,
   i.name,
   case(i.status & 16) when 16 then 'clustered' else '' end,
   case(i.status &  2) when  2 then 'unique'    else '' end,
   case(k.keyno) when 1 then '' else ', ' end + c.name + case (Indexkey_Property(k.id,

k.indid, k.keyno, 'IsDescending')) when 1 then ' desc' else ' asc' end
from
   sysusers u
      join sysobjects o on (o.uid = u.uid)
      join sysindexes i on (i.id = o.id)
      join sysindexkeys k on (k.id = i.id and k.indid = i.indid)
      join syscolumns c on (c.id = k.id and c.colid = k.colid)
where i.indid between 1 and 254
   and i.name not like '%_WA_Sys%' --過濾掉SQL Server自動建立的統計資訊
[  and o.name = %.q:TABLE%]
[  and u.name = %.q:SCHEMA%]
order by
   1, 2, 3, k.keyno

好了,儲存並關掉所有視窗,重新試試PD的Reverse,索引列表中是不是沒有那些統計資訊了?
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.