Grant SELECT on multiple tables oracle

后端 未结 5 646
攒了一身酷
攒了一身酷 2020-12-11 00:37

I have 3 tables table1,table2,table3. I want to grant(select for example) these tables to a user, user1.

I know that I can grant with:

grant select          


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 01:20

    If you want to grant to both tables and views try:

    SELECT DISTINCT
        || OWNER
        || '.'
        || TABLE_NAME
        || ' to db_user;'
    FROM
        ALL_TAB_COLS 
    WHERE
        TABLE_NAME LIKE 'TABLE_NAME_%';
    

    For just views try:

    SELECT
        'grant select on '
        || OWNER
        || '.'
        || VIEW_NAME
        || ' to REPORT_DW;'
    FROM
        ALL_VIEWS
    WHERE
        VIEW_NAME LIKE 'VIEW_NAME_%';
    

    Copy results and execute.

提交回复
热议问题