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

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:

主站蜘蛛池模板: 海淀区| 常熟市| 德令哈市| 武平县| 九江县| 晋江市| 淮滨县| 平原县| 望都县| 紫云| 贡嘎县| 南漳县| 远安县| 昌江| 富阳市| 南皮县| 锦屏县| 慈溪市| 兴宁市| 中超| 阿合奇县| 青川县| 肇源县| 涪陵区| 东辽县| 保靖县| 克什克腾旗| 莲花县| 额敏县| 镇平县| 砚山县| 奈曼旗| 诸暨市| 高安市| 湄潭县| 高陵县| 贵南县| 疏勒县| 乌苏市| 剑阁县| 柘城县|