Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:07:29+00:00 2026-05-18T21:07:29+00:00

username – revoke select to database.Person I set GRANT SELECT (id) ON database.Person TO

  • 0

username – revoke select to database.Person

I set

GRANT SELECT (id) ON database.Person TO 'username'@'localhost'

not is work ->

SELECT secret FROM Person  // Good!

not is work ->

SELECT id FROM Person WHERE secret = 1  // BAD!

I need that would SELECT id FROM Person WHERE secret = 1 is worked!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:07:29+00:00Added an answer on May 18, 2026 at 9:07 pm

    I’m not sure that I’m understanding the question correctly, but it seems to be asking for the ability to restrict the person selecting data from the Persons table so that they cannot see the value in the Secret column, but they should be allowed to use the Secret column in the interior of the query (in the WHERE clause, etc).

    CREATE TABLE Person
    (
        Id      ...,
        Secret  ...,
        ...
    );
    REVOKE ALL ON Person FROM PUBLIC;
    GRANT SELECT(id) ON Person TO SomeOne;
    

    So, if my interpretation is correct, when SomeOne selects data:

    SELECT Id     FROM Person;    -- Works (as required)
    SELECT Secret FROM Person;    -- Fails (as required)
    SELECT Id
      FROM Person
     WHERE Secret = 1;            -- Fails (but we want it to work)
    

    SQL does not allow that, and for good reason. Basically, if you can condition query results on Secret, you can determine the value of Secret with repeated queries, so what is supposed to be secret does not remain a secret. It is very easy to leak information.

    Looking at the query that fails but “shouldn’t”…from its results, you know that every Id returned has the Secret value of 1, so for those Id values, the Secret is no longer secret.

    If you look into Statistical Databases, where you’re only allowed to search on aggregate data, you find there are things called Unique Trackers which basically allow you to identify the characteristics of one person, even if you’re only allowed to see aggregate (SUM, COUNT, …) values in the result sets. This is a more complex scenario than you’re facing (but a fascinating one). C J Date’s (long out of print) “Introduction to Database Systems, Vol II” has a discussion of Statistical Database and Unique Trackers. (Google search on ‘statistical database unique tracker’ reveals useful looking information that is more accessible.)

    So, if I’ve understood what is desired, I believe the desire is misguided — and the SQL standard does not permit what you seek.

    Are there any workarounds?

    If the query can be built into a view, the person creating the view can access the underlying detail data and grant access to the view, but the people using the view cannot execute the raw query; this might give you protection you seek. Similar comments apply to stored procedures and allow the query to be parameterized better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

username = self.request.get('username') groupName = db.GqlQuery(SELECT group FROM Person WHERE name = :1, username).get()
SELECT username, (SELECT follow FROM follow WHERE follow_user_id = user_id) AS following FROM user
SELECT username, (SUM(rating)/count(*)) as TheAverage, count(*) as TheCount FROM ratings WHERE month ='Aug' AND
If I issue SELECT username FROM Users I get this result: username -------- Paul
I have username and password of user stored in my database, like one time
Fabric displays Disconnecting from username@server... done. for almost 2 minutes prior to showing a
How to protect database username and password in shared hosting enviornment using spring <bean
How to get the username value only from the addressbook, when selecting a twitter
I am storing a username/password in NSUserDefaults. I do not want this information to
BACKGROUND: when local username is not the same as the git username, git will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.