テーブルリネームの権限への影響

(8.0.22)

drop table tab1;
create table tab1(col1 int);
grant select on tab1 to user1@'%';

show grants for user1@'%';

alter table tab1 rename to tab1_new;

テーブル権限は継承されない★

 

 

(19c)

drop table tab1 purge;
create table tab1(col1 int);
grant select on tab1 to user1;

select * from user_tab_privs where table_name like 'TAB1%';

alter table tab1 rename to tab1_new;


テーブル権限も継承される

 

 

(14)

drop table tab1;
create table tab1(col1 int);
grant select on tab1 to user1;

\z

alter table tab1 rename to tab1_new;

テーブル権限も継承される

 

 

 

(2019)

drop table tab1;
create table tab1(col1 int);
grant select on tab1 to user1;

select * from sys.database_permissions;

select dper.*,object_name(dper.major_id) tab_name, dpri.name grantee
from sys.database_permissions dper
inner join sys.database_principals dpri
on dper.grantee_principal_id = dpri.principal_id
where dper.major_id in ( OBJECT_ID('tab1_new'),OBJECT_ID('tab1') )
;

EXEC sp_rename 'dbo.tab1', 'tab1_new', 'OBJECT'; 

テーブル権限も継承される