KEMBAR78
Using Data Sharing | PDF
0% found this document useful (0 votes)
8 views1 page

Using Data Sharing

The document outlines SQL commands to create a database, stage, and table for managing order data in Snowflake. It includes commands for loading data from an S3 bucket into the ORDERS table and setting up a share object with appropriate grants for usage and access. Additionally, it demonstrates how to add a consumer account to the share for collaboration purposes.

Uploaded by

riteshkumar96977
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Using Data Sharing

The document outlines SQL commands to create a database, stage, and table for managing order data in Snowflake. It includes commands for loading data from an S3 bucket into the ORDERS table and setting up a share object with appropriate grants for usage and access. Additionally, it demonstrates how to add a consumer account to the share for collaboration purposes.

Uploaded by

riteshkumar96977
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE OR REPLACE DATABASE DATA_S;

CREATE OR REPLACE STAGE aws_stage


url='s3://bucketsnowflakes3';

// List files in stage


LIST @aws_stage;

// Create table
CREATE OR REPLACE TABLE ORDERS (
ORDER_ID VARCHAR(30)
,AMOUNT NUMBER(38,0)
,PROFIT NUMBER(38,0)
,QUANTITY NUMBER(38,0)
,CATEGORY VARCHAR(30)
,SUBCATEGORY VARCHAR(30));

// Load data using copy command


COPY INTO ORDERS
FROM @MANAGE_DB.external_stages.aws_stage
file_format= (type = csv field_delimiter=',' skip_header=1)
pattern='.*OrderDetails.*';

SELECT * FROM ORDERS;

// Create a share object


CREATE OR REPLACE SHARE ORDERS_SHARE;

---- Setup Grants ----

// Grant usage on database


GRANT USAGE ON DATABASE DATA_S TO SHARE ORDERS_SHARE;

// Grant usage on schema


GRANT USAGE ON SCHEMA DATA_S.PUBLIC TO SHARE ORDERS_SHARE;

// Grant SELECT on table

GRANT SELECT ON TABLE DATA_S.PUBLIC.ORDERS TO SHARE ORDERS_SHARE;

// Validate Grants
SHOW GRANTS TO SHARE ORDERS_SHARE;

---- Add Consumer Account ----


ALTER SHARE ORDERS_SHARE ADD ACCOUNT=<consumer-account-id>;

You might also like