List "empty" database groups with no users associated with them. Those groups can be safely dropped:
select * from _v_group
where GROUPNAME not in (select GROUPNAME from _v_groupusers)
and grorsgpercent=0 --- exclude resource Groups
Get DDL for group creation.
nz_ddl_group GRP_MYGROUP
\echo
\echo ***** Creating group: "GRP_MYGROUP "
CREATE GROUP GRP_MYGROUP WITH QUERYTIMEOUT 30 DEFPRIORITY NORMAL MAXPRIORITY NORMAL RESOURCE MINIMUM 1 RESOURCE MAXIMUM 25 ;
List users in a group:
nz_get_group_users GRP_MYGROUP
MYUSER_1
MYUSER_2
...
Get DDLfor group(s) permissions. This is handy to keep in case you need to recreate the group fast.
nz_ddl_grant_group | grep -i GRP_MYGROUP
nz_ddl_grant_group DBASE1 | grep -i GRP_MYGROUP
Same as above only run for all available database in one shot:
nzsql -l -A -r -t
| cut -d'|'-f1
| xargs -I DB nz_ddl_grant_group DB
| grep -i GRP_MYGROUP
| tee -a ~/$(date+'%Y%m%d%H%M%S')_$(hostname)_grant_GRP_MYGROUP.ddl.sql
.
REFERENCE:
The commands used can be found in post:
No comments:
Post a Comment