is it possible to create a Sharing from a snowflake Database? - snowflake-cloud-data-platform

is it possible to share a complete database on snowflake and share it on another snowflake account?
in order that all objects within the shared database are immediately visible in the snowflake subaccount

Related

Snowflake schema creation from a share

Wanted to confirm if it is not possible to create a schema from a share.
I see from the documentation that once a share (from a schema not the entire database) is created/enabled by the provider account,I/the consumer account can only leverage the share by creating a new database.
I/Consumer already have a snowflake database & would like to just point the schema from the provider that is enabled as share to a new schema on my side in the existing database. This avoids the need to maintain multiple databases.
Br,
Noor.
It is not possible.
In consumer side, the ff. command is used to consume a share:
CREATE DATABASE <name> FROM SHARE <provider_account>.<share_name>;
Hence, consumption can only be done in database level. This effectively creates a read-only database (unlike regular/local databases), all of its objects are controlled by the provider.
Additionally, IMPORTED PRIVILEGES is used to grant roles in consumer side access on shared database. Cannot grant this privilege on a Schema.

All tables are shared when setting up snow flake sharing

I created a share in snowflake and assigned permissions to only a few tables. But they can lookup any table.
What's the problem?
I ran it with the script below.
CREATE SHARE test_share
GRANT USAGE ON DATABASE "DBNAME" TO SHARE test_share
GRANT USAGE ON SCHEMA "DBNAME"."SCHEMANAME" TO SHARE test_share
GRANT SELECT ON TABLE "DBNAME"."SCHEMANAME"."TABLENAME" TO SHARE test_share
ALTER SHARE sparc_poc_share ADD ACCOUNTS=ConsumerName;
If sharing tables from the same database via different shares with the same consumer account, when the consumer creates a database from one of the shares, all shared tables are visible in the imported database. To prevent this from happening, create a separate schema for each table you wish to share.
Details: https://docs.snowflake.com/en/user-guide/data-sharing-provider.html#general-data-sharing-considerations-and-usage
Recommended practice: https://docs.snowflake.com/en/user-guide/data-sharing-secure-views.html#using-secure-objects-to-control-data-access

Creating External Tables in Snowflake

Is it possible to create external table in Snowflake referring to on premise Oracle database?
No, Snowflake does not presently support query federation to other DBMS software.
External tables in Snowflake exist only to expose a collection of data files (commonly found in data-lake architectures) as a qualified table without requiring a load first.
Querying your Oracle tables will currently require an explicit export of its data onto a cloud storage location to allow Snowflake to access it.

Snowflake Sample data set

I unable to create objects (views, file format, stage etc.. ) in a shared sample database (SNOWFLAKE_SAMPLE_DATA).
Kindly let me know, what is the possible way to get access the data?
Regards,
DB
The SNOWFLAKE_SAMPLE_DAT database contains a schema for each data set, with the sample data stored in the tables in each schema. You can execute queries on the tables in these databases just as you would any other databases in your account.
The database and schemas do not utilize any data storage so they do not incur storage charges for your account.
however, just as with other databases, executing queries requires a running, current warehouse for your session, which consumes credits.
You can refer to snowflake documentation: DOCS » USING SNOWFLAKE » SAMPLE DATASETS.
Hope this helps answer your question.
Shared databases are read-only. Users in a consumer account can view/query data, but cannot insert or update data, or create any objects in the database. This is why you can not create any objects on the shared database (SNOWFLAKE_SAMPLE_DATA).
https://docs.snowflake.com/en/user-guide/data-share-consumers.html#general-limitations-for-shared-databases
You can query the data in shared database like any other database.
https://docs.snowflake.com/en/user-guide/data-share-consumers.html#querying-a-shared-database

How to share SNOWFLAKE.ACCOUNT_USAGE schema using managed/reader account?

I am trying to share my Snowflake Database(default metadata)--> Account_Usage schema --> Query_History table to another managed account (i.e. reader account) but the data is not visible in another account.
is there any way to share the snowflake database without duplicating the data?
I am getting error as Already Imported Database (i.e) SNowflake cannot be shared for Datashare option.
for a Managed account for usage, I Snowflake database and schemas are available but are not able to see the data which is available.
According to the documentation you can't re-share any database that is shared with you:
Shared databases and all the objects in the database cannot be forwarded (i.e. re-shared with other accounts).
Since the Snowflake database is one that is shared to you from Snowflake, this is probably why you're having issues.
If you need to do this your best bet is to create a table and populate it with the data you need from the Snowflake database and share that table instead. Although it is strange that you'd want to share this info with another account.
Your other option would be to create database/schema in your account with views over the account usage data that you want to share, create a role that can access only that, and then provide a user login with that role only to the group needing to do analytics on your data.

Resources