select *from cdb_ob_database_privilege t1 where t1.tenant_id !=1 and t1.database_name not in ('oceanbase','information_schema','ocp','SYS','LBACSYS','ORAAUDITOR','mysql','__recyclebin','__public','test')
我知道可以这样查询,我的问题是:不知道怎么拼凑成如下SQL,请给出案例,拼凑成如下授权?
grant all on core_AA.* to AAdata;
grant select , delete, insert ,update on core_AA.* to AAdata ;
select TENANT_ID,replace(concat('grant ',
case when PRIV_SELECT='YES' then 'select,' else '' end,
case when PRIV_INSERT='YES' then 'insert,' else '' end,
case when PRIV_UPDATE='YES' then 'update,' else '' end,
case when PRIV_DELETE='YES' then 'delete,' else '' end,
case when PRIV_ALTER='YES' then 'alter,' else '' end,
case when PRIV_CREATE='YES' then 'create,' else '' end,
case when PRIV_DROP='YES' then 'drop,' else '' end,
case when PRIV_INDEX='YES' then 'create index,' else '' end,
case when PRIV_SHOW_VIEW='YES' then 'show view,' else '' end,
' on ',t1.DATABASE_NAME,'.* to ',t1.username,';'),', on',' on') grant_sql from cdb_ob_database_privilege t1
where t1.tenant_id !=1 and t1.database_name not in ('oceanbase','information_schema','ocp','SYS','LBACSYS','ORAAUDITOR','mysql','__recyclebin','__public','test')