Re: SQL to determine permissions?
Posted in 2006
William Fields wrote:
> Anyone know if there's an Informix system table SQL that'll return the
> current permissions in force for the current connection on a given object
> (table,view,sp etc...)?
Tables, synonyms, and views are all treated as tables, so:
select grantee, tabauth
from systabauth sta, systables st
where st.tabname = 'mytable'
and st.tabid = sta.tabid
and sta.grantee IN (USER, 'public');
The results are in a form similar to the perms output of the UNIX ls -l
command. See the Guide to SQL Reference for details, but quickly any letter
d indicates delete permissions, i - insert, u update, x - index, s - select.
You need to filter grantee for USER or 'public' because any table that you
do not have specific permissions on you will get the pseudouser 'public's
perms for. If you are using roles you may also have to search on the user's
role's permissions.
For other objects, you can perform similar queries:
columns: join systables -> syscolumns -> syscolauth
procedures/functions: join sysprocedures -> sysprocauth
fragmented tables: join systables -> sysfragments -> sysfragauth
roles user has permissions to:
select rolename from sysroleauth where grantee = USER;
Art S. Kagel