Ask the Expert

Limiting table access with a stored procedure

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.

    Requires Free Membership to View

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.

This was first published in June 2007

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: