I want to create a view from another view that I have select statement privilege. However, I can't and I am getting this error. Do you know why? Do I need other type of Select privilege?
SET CURRENT SCHEMA = SCHEMA1;
CREATE VIEW NEWSCHEMA.MYVIEW AS SELECT * FROM DB1.SCHEMA1.VIEW1
WITH NO ROW MOVEMENT;
SET CURRENT SCHEMA = NEWSCHEMA;
COMMIT;
full error msg:
Category Line Position Timestamp Duration Message Error 3 0 01/27/2023 11:24:05 AM 0:00:00.007 - DB2 Database Error: ERROR [42501] [IBM][DB2/AIX64] SQL0551N The statement failed because the authorization ID does not have the required authorization or privilege to perform the operation. Authorization ID: "NEWSCHEMA". Operation: "SELECT". Object: "SCHEMA1.VIEW1".
SELECT GRANTEE, GRANTEETYPE, CONTROLAUTH, SELECTAUTH FROM SYSCAT.TABAUTH WHERE (TABSCHEMA, TABNAME) = ('SCHEMA1', 'VIEW1') AND GRANTEETYPE IN ('U', 'R')
The reason is highly like because of the following CREATE VIEW authorization requirement:
So, you may really have an ability to SELECT from this view, but you probably have it via some group membership, but not personally or via some role.
This is the reason you get this error.
You may ask your SECADM or view owner grant your authorization id a
SELECT
privilege to resolve the problem.