how to compare/validate sql schema

后端 未结 11 676
后悔当初
后悔当初 2021-02-02 16:02

I\'m looking for a way to validate the SQL schema on a production DB after updating an application version. If the application does not match the DB schema version, there should

11条回答
  •  醉话见心
    2021-02-02 16:06

    Try this SQL.
    - Run it against each database.
    - Save the output to text files.
    - Diff the text files.

    /* get list of objects in the database */
    SELECT name, 
           type 
    FROM  sysobjects
    ORDER BY type, name
    
    /* get list of columns in each table / parameters for each stored procedure */
    SELECT so.name, 
           so.type, 
           sc.name, 
           sc.number, 
           sc.colid, 
           sc.status, 
           sc.type, 
           sc.length, 
           sc.usertype , 
           sc.scale 
    FROM   sysobjects  so , 
           syscolumns  sc 
    WHERE  so.id = sc.id 
    ORDER BY so.type, so.name, sc.name
    
    /* get definition of each stored procedure */
    SELECT so.name, 
           so.type, 
           sc.number, 
           sc.text 
    FROM   sysobjects  so , 
           syscomments sc 
    WHERE  so.id = sc.id 
    ORDER BY so.type, so.name, sc.number 
    

提交回复
热议问题