Problem solve Get help with specific problems with your technologies, process and projects.

Limiting table access with a stored procedure

An expert describes how to limit table access and viewing with a stored procedure instead of the GRANT statement.

I want to allow my users to access a table for a single-use. I know that you can limit queries within an hour. Is there a way to limit them on a per-use basis? I want the privileges to be revoked once they're finished looking at it.

The GRANT statement provides the following access limitations on a user:

  • The number of queries per hour
  • The number of updates per hour
  • The number of connections to the server per hour
  • The number of simultaneous connections to the server

There is no built in method to limit the number of times a user may access a particular table outside of the per hour limits.

You can use stored procedures to limit user access to data. Construct a stored procedure that logs user access to the table (referencing the CURRENT_USER() function as needed), and exits early if the table has already been accessed. Give your users access only to the stored procedure, and not directly to the table itself.

Dig Deeper on Linux servers

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.