官术网_书友最值得收藏!

Modifying a table structure

Like it or not, database tables change. Due to upgrades in source systems, mergers and acquisitions, or simply because of a shift in the project management, we suddenly find that an SKU or a customer ID is not there anymore. Let alone systems in continuous development where the database seems to have a life of its own and morphs every now and then into different shapes. We all know how difficult it is to go back and test every ETL script and every report to see if they still return reliable data.

Sometimes changes happen without notice, you come to the office on a Monday morning to see that the CFO has a different color…, then you realize that something went wrong.

There is no vaccine for this, other than carefully documenting everything and hope for the best. Let's see how to refresh our table structure information using the Warehouse Catalog window.

Getting ready

You need to have completed the previous recipe and exercises to continue.

How to do it...

First of all, we will modify the structure of the DimDate table to add a column with the month's description:

  1. In command prompt type:
    sqlcmd -S (localdb)\v11.0 -d AdventureWorksDW2008R2
    
  2. Once the 1> prompt appears, type:
    ALTER TABLE DimDate ADD CalendarYearMonth VARCHAR(7)
    go
    UPDATE DimDate SET CalendarYearMonth = CONVERT(VARCHAR(7), FullDateAlternateKey, 111)
    go
    exit
    
  3. Now go to the Warehouse Catalog window and right-click on the table DimDate in the right pane and select Show Sample Data.
  4. See that there is a new column at the end named CalendarYearMonth with the format YYYY/MM.
  5. Click on Close and right-click again on DimDate, then select Update Structure.
  6. Now click on Save and Close to exit this window, MicroStrategy will write the changes to the metadata.
  7. Update the schema.

How it works...

It's very important to keep the metadata consistent with the latest information about the structure of the database, especially when changing the datatypes or when columns are removed from data warehouse tables.

Note

You can watch a screencast of this operation at:

主站蜘蛛池模板: 南靖县| 达尔| 盱眙县| 炉霍县| 石屏县| 永德县| 得荣县| 扶沟县| 密山市| 石家庄市| 贺兰县| 林周县| 谢通门县| 石棉县| 曲阜市| 博白县| 扎兰屯市| 晴隆县| 岳西县| 苏尼特左旗| 天全县| 迭部县| 齐齐哈尔市| 会泽县| 方山县| 南江县| 元谋县| 宜兰市| 固阳县| 北票市| 宜阳县| 香格里拉县| 彰化市| 丰宁| 南部县| 麻栗坡县| 新和县| 石渠县| 中江县| 江北区| 汕头市|