Set up a user to query a table

This article shows how an administrator can add a user, create a table containing 10 million people records from a Databricks dataset, and allow a user to access the table. Next, it shows how the user can run a query and view the query runtime details.


Data access control is always enabled in Databricks SQL, which means that users must always be granted access to data.


  • You must be a Databricks workspace admin.


SQL warehouses won’t start if you do not provision the required amount of CPU and storage resources. See Compute Engine API. If needed, you can increase the resource quotas to support your use of SQL warehouses. See Review and increase quotas. For information about workspace cost, see cost per workspace.

Step 1: Add a user

Step 2: Create a table of 10 million people

  1. Click New in the sidebar and select Query.

  2. In the drop-box at the left, select a SQL warehouse, such as Starter Warehouse.

  3. Paste the following in the SQL editor:

    CREATE TABLE default.people10m OPTIONS (PATH 'dbfs:/databricks-datasets/learning-spark-v2/people/')

    This statement creates a Delta table using Delta Lake files stored in Databricks datasets.

  4. Press Ctrl/Cmd + Enter or click the Execute button. The query will return No data was returned.

  5. To refresh the schema, click the Refresh Schema button at the bottom of the schema browser.

  6. Type peo in the text box to the right of the schema. The schema browser displays the new table.

    Schema browser

Step 3: Configure access to the default.people10m table

Enable the user you created in Step 1 to access the default.people10m table you created in Step 3.

You can configure access using Catalog Explorer or SQL editor.

Catalog Explorer

  1. Click Catalog in the sidebar.

  2. In the drop-down list at the top right, select a SQL warehouse, such as Starter Warehouse. The default schema is selected. The schema comment and owner display.

  3. Type peo in the text box following the default schema. Catalog Explorer displays the people10m table.

  4. Click the Permissions tab.

  5. Click the Grant button.

    Default db grant
  6. Enter

  7. Select the USAGE checkbox.

  8. Click OK.

  9. Click the people10m table.

  10. Click the Permissions tab.

  11. Click the Grant button.

    People table grant
  12. Enter

  13. Click the SELECT and READ_METADATA checkboxes.

  14. Click OK.

SQL editor

  1. Click New in the sidebar and select Query.

  2. In the drop-down box at the left, select a SQL warehouse, such as Starter Warehouse.

  3. Enter the following queries one by one:

    GRANT USAGE ON SCHEMA default TO ``;
    GRANT SELECT, READ_METADATA ON TABLE default.people10m TO ``;
    SHOW GRANTS `` ON TABLE default.people10m;

    After each query, press Ctrl/Cmd + Enter or click the Execute button. After the last query, it should display:

    | Principal        | ActionType    | ObjectType | ObjectKey             |
    | | READ_METADATA | TABLE      | `default`.`people10m` |
    | | SELECT        | TABLE      | `default`.`people10m` |
    | | USAGE         | SCHEMA     | default               |

Step 5: Generate a query

Complete the user quickstart.

Step 6: View query history

  1. Click Query History in the sidebar.

  2. Click a string in the Query column to display query details:

    Query history details

Next steps

To learn how to enable access to your own data and tables, see Access control overview.

To walk through the process to enable access, go to the Get Started pane on https://<databricks-instance>/sql, replacing <databricks-instance> with the Databricks workspace instance name, for example