IBM Support

Limiting what SQL statements a user is allowed to run

News


Abstract

This document will explain how to limit what SQL statements a user is allowed to run.

Content

SQL is just another interface that can be used to access database files. SQL uses the standard IBM i authority the user has to the file. For example, if they have delete data authority to the file, they can delete rows from any interface (RPG, SQL, DFU, etc). Because SQL is powerful, many administrators would like to limit the SQL statements a user is allowed to run (only select statement). There is no OS function that would achieve this.  You have the following options to limit certain SQL activity:

1. Limit SQL activity to the Query Manager product (STRQM). Each system user profile has a Query Manager profile and you can limit what SQL statements a user is allowed to use in the Query Manager product. You can do this by doing the following:

a. STRQM and take option 10

b. Put a 2 next to the profile you want to limit.

c. Page down and change Select allowed SQL statements to a Y.

d. Now you have the ability to only select the SQL statements you want this user to use.

NOTE: This does not set this for all SQL interfaces for this user - only when the user is using STRQM.

2. Use exit programs or create your own SQL program to capture the SQL statement the user is wanting to run and determine if the SQL should be allowed to run or not.  You would need to look at each application or connection to determine what exit programs are available.

If running SQL from an application using ODBC or JDBC driver to connect some exit points are available:
www.ibm.com/docs/en/i/7.5?topic=performance-exit-programs
The exit point program can capture the SQL request and either allow the request to be processed or reject the request. 
The exit point program could also log what SQL is being executed.
 
QIBM_QZDA_INIT
QIBM_QZDA_NDB1
QIBM_QZDA_SQL1
QIBM_QZDA_SQL2
QIBM_QZDA_ROI1
 

3. Limit the authority to to the database file to read only. Any application that the user needs to edit the data would need to use adopted authority to allow the necessary authority.  More informaiton at: https://www.ibm.com/support/pages/node/683193

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000001iIgAAI","label":"IBM i Db2-\u003ERUNSQL, RUNSQLSTM, STRSQL"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Document Information

More support for:
IBM i

Component:
IBM i Db2->RUNSQL, RUNSQLSTM, STRSQL

Software version:
All Versions

Operating system(s):
IBM i

Document number:
688129

Modified date:
04 December 2024

UID

nas8N1022600

Manage My Notification Subscriptions