Purpose
oragrant prints all existing grants in an Oracle database schema.
It can also be used to execute these grant statements directly.
Options
oragrant supports the following options:
connectstringAn Oracle connectstring.
-v,--verbose(false,no,0,true,yesor1)Produces output (on stderr) while the database is read or written.
-c,--color(yes,noorauto)Should the output (when the
-voption is used) be colored? Ifautois specified (the default) then the output is colored if stderr is a terminal.-x,--execute(connectstring)When the
-xargument is given the SQL script isn't printed on stdout, but executed in the database specfied as the-xargument.-k,--keepjunk(false,no,0,true,yesor1)If true (the default), database objects that have
$orSYS_EXPORT_SCHEMA_in their name will be skipped (otherwise these objects will be included in the output).-i,--ignore(false,no,0,true,yesor1)If true, any exception that occurs while the database is read or written will be ignored.
-m,--mapgrantee(Python expression:listordict)A Python
dictorlistliteral which will be evaluated. If the grantee is not in this list (or dictionary) no grant statement will be returned. If it's a dictionary and the grantee exists as a key, the privilege will be granted to the user specified as the value instead of the original one. The default is to grant all privileges to the original grantee.--format(sqlorpysql)If
--executeis not given, this determines the output format: Plain SQL, or PySQL which can be piped intoll.pysql.--include(regexp)Only include objects in the output if their name contains the regular expression.
--exclude(regexp)Exclude objects from the output if their name contains the regular expression.
Example
Grant all privileges that alice has in the schema user@db to bob in
user2@db2:
$ oragrant user/pwd@db -x user2/pwd2@db2 -m '{"alice": "bob"}' -v