It is required to execute repetitive DCL (Data Control Language) statements on certain tables in the database. How can I generate them automatically?
Sentence to generate:
GRANT DELETE, INSERT, SELECT, UPDATE ON NOMBRETABLA TO ADMINISTRADOR;
It must be applied on all the tables that start with FAM_
Expected result after executing the query:
GRANT DELETE, INSERT, SELECT, UPDATE ON FAM_TABLA_A TO ADMINISTRADOR;
GRANT DELETE, INSERT, SELECT, UPDATE ON FAM_TABLA_B TO ADMINISTRADOR;
GRANT DELETE, INSERT, SELECT, UPDATE ON FAM_PRUEBA TO ADMINISTRADOR;
GRANT DELETE, INSERT, SELECT, UPDATE ON FAM_TABLAC TO ADMINISTRADOR;
Updates:
Use a select to concatenate GRANT DELETE, INSERT, SELECT, UPDATE ON
with the name of all the tables that start with FAM_
...
First idea: put the tables you need to work on in a new table, let's say call it,
listatablas
and then run something likeSecond idea: if you have sufficient permissions with the user with which you connect to your database, you can get all the tables from the view
dba_tables
:If your user does not have sufficient permissions, you could use
all_tables
instead ofdba_tables
:Based on: Get list of all tables in Oracle?