Search code examples
db2db2-luw

migrating from db2 Express-C to Developer version


I have a backup file from db2 express-c 11.1 version and I'd like to restore it into db2 developer version (both on Windows machine). The RESTORE completed successfully and I can list the tables from the db2 command line

db2 list tables for schema XYZ

but when I'm trying to access the data I'm getting the following error message

SQL0551N  The statement failed because the authorization ID does not have the
required authorization or privilege to perform the operation.  Authorization
ID: "DB2USER".  Operation: "SELECT". Object: "XYZ.Table1".  SQLSTATE=42501

I logged in as the user who RESTORE the database. WHat's the issue here?


Solution

  • When restoring a DB2-luw database backup to a different Db2-instance , it is wise to first set a Db2-registry variable on the target Db2-instance before performing the database-restore. The account performing the Db2-restore will then be granted SECADM, DBADM, DATAACCESS, and ACCESSCTRL authorities on the restored database.

    db2set DB2_RESTORE_GRANT_ADMIN_AUTHORITIES=on  
    

    More information here.

    Then perform the Db2-restore command.

    If you have not taken this action then you can also use manual GRANT statements (on database level and object level) to adjust to the new Db2-instance, but for best results you should use the registry variable above.

    You can also use the TRANSFER OWNERSHIP statement at various levels to achieve the security model. Details here. This is useful when the previous owner was the Db2-instance and the restored-database is in a different Db2-instance than the backed-up-database.