2010/04/13

Adding Foreign Key Constraints using OMB+


To add a new foreign key to an existing table using OMB+, the syntax is

For Eg: Sales_Fact has a column Order_Date_Key and a new FK needs to be created. This Order_Date_Key is populated with the PK of Time_Dim. To implement this, the OMB+ syntaxt is -

OMBALTER TABLE 'SALES_FACT' ADD FOREIGN_KEY 'FK_SALFACT_TIME_DIM' \
SET REF COLUMMNS ('ORDER_DATE_KEY') \
SET REFERENCE PRIMARY_KEY 'DIMENSION_KEY' OF TABLE 'TIME_DIM'.

No comments:

Post a Comment

File Handling with Python

This little utility is for copying files from source to target directories.  On the way it checks whether a directory exists in the target, ...