Suggestions on storing view meta in SQL Server 2008

↘锁芯ラ 提交于 2019-12-11 11:09:34

问题


I want to store the view meta info like on which tables & columns & queries its created etc, into another mapping table,so that I can reproduce them later point of time.

Right now I have a structure like this -

CREATE TABLE [dbo].[MAPPING_VIEW]
(
    [ID] [int] NOT NULL,
    [OLD_VIEW] [varchar](40) NULL,
    [NEW_VIEW] [varchar](40) NULL,

    CONSTRAINT [PK_MAPPING_VIEW] PRIMARY KEY CLUSTERED 
    ([ID] ASC)
) 

CREATE TABLE [dbo].[MAPPING_VIEW_TBL]
(
    [ID] [int] NULL,
    [PARENT_ID] [int] NULL,
    [OLD_TBL] [varchar](40) NULL,
    [NEW_TBL] [varchar](40) NULL
) 

ALTER TABLE [dbo].[MAPPING_VIEW_TBL] WITH NOCHECK 
ADD CONSTRAINT [FK_MAPPING_VIEW_TBL_ID] 
FOREIGN KEY([PARENT_ID]) REFERENCES [dbo].[MAPPING_VIEW] ([ID])

CREATE TABLE [dbo].[MAPPING_VIEW_TBL_COL]
(
    [ID] [int] NULL,
    [PARENT_ID] [int] NULL,
    [VIEW_ID] [int] NULL,
    [OLD_COL] [varchar](40) NULL,
    [NEW_COL] [varchar](40) NULL,
    [OLD_ALIAS] [varchar](40) NULL,
    [NEW_ALIAS] [varchar](40) NULL
)

ALTER TABLE [dbo].[MAPPING_VIEW_TBL_COL] WITH NOCHECK 
ADD CONSTRAINT [FK_MAPPING_VIEW_TBL_COL_PARENT_ID] 
FOREIGN KEY([PARENT_ID]) REFERENCES [dbo].[MAPPING_TBL] ([ID])

ALTER TABLE [dbo].[MAPPING_VIEW_TBL_COL]  WITH NOCHECK 
ADD CONSTRAINT [FK_MAPPING_VIEW_TBL_COL_VIEW_ID] 
FOREIGN KEY([VIEW_ID]) REFERENCES [dbo].[MAPPING_VIEW] ([ID])

I know, which is not enough. Any suggestions would be appreciated

来源:https://stackoverflow.com/questions/11032306/suggestions-on-storing-view-meta-in-sql-server-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!