Is it possible to grant sql access to schema?
Hi folks!
Here is how I grant SQL access of user to a particular class/table:
GRANT SELECT, UPDATE ON Packacge_X.Table_Y TO UserZ
How can I grant SQL access of a certain user to a whole schema?
Product version: IRIS 2020.4
GRANT SELECT, UPDATE ON SCHEMA Packacge_X TO UserZ
Thanks Stefan! This is what I was looking for!
Hi
According to the documentation you can GRANT priveledges to a Class/Table and you can use a wildcard "*" for a collection of Classes/Tables
The documentation reference in the Ensemble documentation is:
http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_grant
and in the explanation there is an example:
and further on the documentation says:
A comma-separated list of one or more tables, views, stored procedures, or cubes for which the object-privilege(s) are being granted. You can use the SCHEMA keyword to specify granting the object-privilege to all objects in the specified schema. You can use “*” to specify granting the object-privilege to all tables, or to all non-hidden Stored Procedures, in the current namespace. Note that a cubes object-list requires the CUBE (or CUBES) keyword, and can only be granted SELECT privilege.
The full syntax is:
An administrative-level privilege or a comma-separated list of administrative-level privileges being granted. The list may consist of one or more of the following in any order:
%CREATE_METHOD, %DROP_METHOD, %CREATE_FUNCTION, %DROP_FUNCTION, %CREATE_PROCEDURE, %DROP_PROCEDURE, %CREATE_QUERY, %DROP_QUERY, %CREATE_TABLE, %ALTER_TABLE, %DROP_TABLE, %CREATE_VIEW, %ALTER_VIEW, %DROP_VIEW, %CREATE_TRIGGER, %DROP_TRIGGER
%DB_OBJECT_DEFINITION, which grants all 16 of the above privileges.
%NOCHECK, %NOINDEX, %NOLOCK, %NOTRIGGER privileges for INSERT, UPDATE, and DELETE operations.
In IRIS look at the documentation at this link:
%SYSTEM.SQL.Security
You can check priveledges with:
Methods
classmethod CheckPrivilege(Username As %String, ObjectType As %Integer, Object As %String, Action As %String, Namespace As %String = "") as %Boolean [ Language = objectscript ]
Check if user has SQL privilege for a particular action. This does not check grant privileges. Parameters:
Returns:
Notes:
and you can set Priveledges with
classmethod GrantPrivilege(ObjPriv As %String, ObjList As %String, Type As %String, User As %String) as %Status [ Language = objectscript ]
GrantPrivilege lets you grant an ObjPriv to a User via this call instead of using the SQL GRANT statement. This does not include grant privileges.
$SYSTEM.SQL.Security.GrantPrivilege(ObjPriv,ObjList,Type,User)
classmethod GrantPrivilegeWithGrant(ObjPriv As %String, ObjList As %String, Type As %String, User As %String) as %Status [ Language = objectscript ]
GrantPrivilegeWithGrant lets you grant an ObjPriv, WITH GRANT OPTION, to a User
$SYSTEM.SQL.Security.GrantPrivilegeWithGrant(ObjPriv,ObjList,Type,User)
Nigel