Private notebooks

In Snowsight, you can create a private, user-owned notebook. This private notebook is stored in your personal database: a dedicated workspace where you can create, modify, and manage your private notebooks. Unlike with role-based ownership, objects within a personal database are owned by an individual user. You can create private notebooks in a personal database without having to wait for someone to grant you the appropriate privileges.

Note

The lifecycle of a personal database is directly linked to its owner. If a user is removed from the Snowflake account, their personal database is also deleted. Therefore, Snowflake recommends against using personal databases for business-critical or production workloads.

Your personal database is named after your username in the form USER$username (for example, USER$JOHNDOE). You can also reference it with the prefix USER$. You can view details for your personal database in Data » Databases.

A private notebook enables you to do the following tasks:

  • Privately develop code interactively and experiment with data and models.

  • Deploy these projects by duplicating notebooks from personal databases to regular, non-personal databases.

Note

Users cannot create tables or other objects in a personal database. For a complete list of limitations and restrictions, see Limitations.

Prerequisites for using private notebooks

Before you create and use private notebooks, an administrator with the ACCOUNTADMIN role must complete the following tasks:

Important

After the administrator has enabled personal databases, affected users must sign out and sign back in to see the new user interface behavior.

For details on creating a private notebook, see Create a new notebook.

Activating all secondary roles for private notebook users

Before you create a private notebook, all secondary roles must be enabled. This is because private notebooks are owned by the user, not their primary role.

To activate all secondary roles of a user by default, the user or an administrator can use the ALTER USER command to either unset the DEFAULT_SECONDARY_ROLES object property or set it to (‘ALL’) for the user.

For example:

ALTER USER my_user UNSET DEFAULT_SECONDARY_ROLES;
ALTER USER my_user SET DEFAULT_SECONDARY_ROLES = ('ALL');
Copy

After the user or an administrator executes the SQL statement above, the user can create a private notebook in Snowsight (Projects » Notebooks) or by executing SQL commands in a new worksheet.

A user who wants to execute SQL commands in an existing worksheet must execute the following SQL statement before creating a private notebook:

USE SECONDARY ROLES ALL;
Copy

Enable and disable private notebooks for the account

To enable or disable private notebooks on a Snowflake account, use the ENABLE_PERSONAL_DATABASE parameter.

Properties of ENABLE_PERSONAL_DATABASE:

Type:

User — Can be set for Account > User

Data Type:

Boolean

Description:

Controls whether users have access to private notebooks.

Values:

TRUE: Enables users to access their personal databases.

FALSE: Prevents users from accessing their personal databases.

Default:

FALSE

Examples

To enable private notebooks for the account, use the ALTER ACCOUNT command to set the ENABLE_PERSONAL_DATABASE parameter to TRUE. For example:

ALTER ACCOUNT SET ENABLE_PERSONAL_DATABASE = TRUE;
Copy

You cannot alter a different account; you can only alter the current account. For more information about this command, see ALTER ACCOUNT.

To disable private notebooks for the account, run the same command but set the parameter to FALSE. For example:

ALTER ACCOUNT SET ENABLE_PERSONAL_DATABASE = FALSE;
Copy

To check the current value of the ENABLE_PERSONAL_DATABASE parameter, run the following SHOW PARAMETERS command:

SHOW PARAMETERS LIKE 'ENABLE_PERSONAL_DATABASE' IN ACCOUNT;
Copy

After the administrator enables the parameter for the account, a user must sign out and sign back in. Then the user can check that the personal database has been created by running a USE DATABASE command:

USE DATABASE USER$;
Copy

You can name the current user explicitly by specifying the USER$ prefix followed by the login username. For example:

USE DATABASE USER$bobr;
Copy

These commands succeed when the personal database for the current user exists. The USE DATABASE command returns an error if the personal database does not exist (because the prerequisite tasks were not completed) or if it is not the current user’s personal database. For example, if jlap is not the current user, the following message appears:

USE DATABASE USER$jlap;
Copy
ERROR: Insufficient privileges to operate on database 'USER$JLAP'

Note

  • Personal databases do not have a specific owner; they are system-owned objects.

  • You cannot create personal databases yourself. They are “lazily created” in the background for existing users when the account is enabled for private notebooks. The first time a user runs a command with explicit USER$ name resolution, the personal database is created. For example, running the command USE DATABASE USER$ results in lazy creation of the personal database for the current user.

Enabling and disabling private notebooks for individual users

Administrators may want specific users in the account to have personal database access, rather than all users in the account. To enable access for given users, use the ALTER USER command to set the ENABLE_PERSONAL_DATABASE parameter to TRUE for those users. For example, enable access for three users:

ALTER USER bobr SET ENABLE_PERSONAL_DATABASE = TRUE;
ALTER USER amya SET ENABLE_PERSONAL_DATABASE = TRUE;
ALTER USER jlap SET ENABLE_PERSONAL_DATABASE = TRUE;
Copy

If you enable personal databases at the account level, you can disable personal databases for individual users, as needed. To disable users, run the same command but set the parameter to FALSE. For example:

ALTER USER jlap SET ENABLE_PERSONAL_DATABASE = FALSE;
Copy

If user jlap specifies the USER$ prefix in any command, the command will fail because the personal database does not exist.

NotebookSqlException: Failed to fetch a pandas Dataframe. The error is: 060109 (0A000): Personal Database is not enabled for user JLAP.
Please contact an account administrator to enable it and try again.

Note

If you enable and then disable personal databases for a specific user, the user loses access to the personal database that was created but the database continues to exist.

Create a private notebook

To create a new private notebook, follow these steps:

  1. Sign in to Snowsight.

  2. Select Projects » Notebooks in the left-side navigation menu.

  3. Select + Notebook.

  4. Select your username from the Owner list.

  5. Enter a name for your notebook.

    Note

    If you’re using an AWS region, you can specify the runtime environment for your notebook: either Warehouse Runtime or Container Runtime.

  6. Select a Notebook location. This is the database and schema in which to store your notebook. These cannot be changed after you create the notebook. If you create a private notebook after personal databases are enabled for your account, your personal database will be pre-populated by default under Notebook location. However, if you are creating a private notebook and there is only one schema in your personal database, the Notebook location options are not available.

    Note

    The Notebook location dropdown might not show databases that were created after you opened the Create Notebook dialog. If you can’t find your recently created database, schema, or warehouse, try reloading your browser window.

    Querying data in the notebook is not restricted to this location. In the notebook, you can query data in any location you have access to. To specify the location, run USE WAREHOUSE and USE SCHEMA.

  7. Select Run on warehouse or Run on container as your Python environment.

  8. Optional Select a Query warehouse to run any SQL and Snowpark queries issued by the notebook.

  9. Select a Notebook warehouse to run notebook-specific tasks. Snowflake recommends that you use SYSTEM$STREAMLIT_NOTEBOOK_WH, a Snowflake-managed warehouse that is provisioned in each account for running notebooks.

  10. Select Create to create and open your notebook.

Organize your private notebooks

You can create and use schemas as a means of organizing your private notebooks. By default, personal databases contain the standard schemas named PUBLIC and INFORMATION_SCHEMA.

Create and use new schemas in the usual way, but make sure you are using your personal database when you create schemas. For example:

USE DATABASE USER$bobr;
CREATE SCHEMA bobr_schema;
USE SCHEMA bobr_schema;
Copy

You can also use the ALTER SCHEMA command on schemas in personal databases, and you can use the SHOW SCHEMAS command to see the schemas that belong to personal databases. For example:

ALTER SCHEMA bobr_schema RENAME TO bobr_personal_schema;
SHOW TERSE SCHEMAS;
Copy
+-------------------------------+----------------------+------+---------------+-------------+
| created_on                    | name                 | kind | database_name | schema_name |
|-------------------------------+----------------------+------+---------------+-------------|
| 2024-10-28 19:33:18.437 -0700 | BOBR_PERSONAL_SCHEMA | NULL | USER$BOBR     | NULL        |
| 2024-10-29 14:11:33.267 -0700 | INFORMATION_SCHEMA   | NULL | USER$BOBR     | NULL        |
| 2024-10-28 12:47:21.502 -0700 | PUBLIC               | NULL | USER$BOBR     | NULL        |
+-------------------------------+----------------------+------+---------------+-------------+

Making a private notebook available for general use

At some point in its development, you may want to recreate your notebook outside your personal database. To make this change, duplicate the original notebook using a CREATE NOTEBOOK command. When you do this, the notebook becomes visible to other users.

For example:

CREATE NOTEBOOK bobr_prod_notebook
  FROM 'snow://notebook/USER$BOBR.PUBLIC.bobr_private_notebook/versions/version$1/'
  QUERY_WAREHOUSE = 'PUBLIC_WH'
  MAIN_FILE = 'notebook_app.ipynb'
  COMMENT = 'Duplicated from personal database';
Copy
Notebook BOBR_PROD_NOTEBOOK successfully created.

You can also create a private notebook from a notebook that was created in a production database.

Note

You cannot complete this task via the Snowsight user interface; you must use an explicit SQL command (in a SQL cell of a notebook or in a worksheet, for example).

FROM 'source_location'

Specifies that the notebook should be created from an .ipynb file in the specified stage location:

  • To create the notebook from a file on a stage, set source_location to the stage location of the file, and set the MAIN_FILE parameter to the name of the file.

  • To create the notebook from a private notebook (for example, to make a private notebook available for shared use), set this parameter to:

    'snow://notebook/USER$username.schema.notebook/versions/version$1/'

    Where:

    • username is your user name.

    • schema is the name of the schema that contains the private notebook.

    • notebook is the name of the private notebook.

If this parameter is not specified, the notebook object is created from a template notebook.

Viewing information about private notebooks and personal databases

Individual users can use Snowsight to view information about their notebooks. Go to Projects » Notebooks. The owner of the notebook is listed as the user.

For information about databases, including personal databases, go to Data » Databases. You can easily see which databases are personal databases because they have the USER$ prefix.

Administrator visibility

Roles with the MANAGE GRANTS privilege have visibility into all objects within the account, including personal objects owned by individual users. For example, roles like ACCOUNTADMIN can view all databases, including personal databases, by default. These roles can also access details about schemas and private notebooks within personal databases.

To view details for all personal databases within an account, query the DATABASES Account Usage view:

SELECT * FROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES;
Copy

Administrators can use DESCRIBE NOTEBOOK to view properties about a specific private notebook:

DESCRIBE NOTEBOOK USER$.PUBLIC.bobr_private_notebook;
Copy

On the Projects » Notebooks page in Snowsight, administrators cannot see private notebook objects that belong to other users in the Notebooks list.

To show a current user’s personal database:

SHOW DATABASES LIKE 'USER$BOBR';
Copy

For personal databases, the value in the kind column is PERSONAL DATABASE.

Limitations

Private notebook limitations

  • Private notebooks cannot be scheduled.

Personal database limitations

  • Users can only create private notebooks and schemas inside a personal database. For example, tables cannot be created and loaded.

  • Users cannot alter, clone, or replicate their personal database.

  • Users cannot move schemas between personal and non-personal databases.

  • Personal databases cannot be shared with roles.

  • Administrators cannot add a personal database to a replication group for the purpose of replication.

  • Users cannot share objects in personal databases.

  • Users cannot add a personal database to native apps (app packages).

  • Users and administrators cannot drop and/or rename the USER$.PUBLIC schema.

Collaboration limitations

  • Administrators cannot create database roles.

  • Users and administrators cannot grant any CREATE <object> privileges on their schemas to others.

  • Users cannot grant privileges on their objects to shares or to application packages.

  • Users cannot grant the REFERENCE_USAGE privilege on their personal database to shares or packages.

  • Users cannot add a personal database to a share (for the purpose of sharing across accounts).