Query the information_schema database

Hive supports the ANSI-standard information_schema database, which you can query for information about tables, views, columns, and your Hive privileges. The information_schema data reveals the state of the system, similar to sys database data, but in a user-friendly, read-only way. You can use joins, aggregates, filters, and projections in information_schema queries.

One of the following steps involves changing the time interval for synchronization between HiveServer and the policy. HiveServer responds to any policy changes within this time interval. You can query the information_schema database for only your own privilege information.

  1. Open Ranger Access Manager, and check that the preloaded default database tables columns and information_schema database policies are enabled for group public.
  2. Navigate to Services > Hive > Configs > Advanced > Custom hive-site.
  3. Add the hive.privilege.synchronizer.interval key and set the value to 1.
    This setting changes the synchronization from the default one-half hour to one minute.
  4. From the Beeline shell, start Hive, and check that Ambari installed the information_schema database:
    SHOW DATABASES;
    ...
    +---------------------+
    |    database_name    |
    +---------------------+
    | default             |
    | information_schema  |
    | sys                 |
    +---------------------+
  5. Use the information_schema database to list tables in the database.
    USE information_schema;
    ...
    SHOW TABLES;
    ...
    +--------------------+
    |      tab_name      |
    +--------------------+
    | column_privileges  |
    | columns            |
    | schemata           |
    | table_privileges   |
    | tables             |
    | views              |
    +--------------------+
  6. Query the information_schema database to see, for example, information about tables into which you can insert values.
    SELECT * FROM information_schema.tables WHERE is_insertable_into='YES' limit 2;
    ...
    +--------------------+-------------------+-----------------
    |tables.table_catalog|tables.table_schema|tables.table_name
    +--------------------+-------------------+-----------------
    |default             |default            |students2
    |default             |default            |t3