0% found this document useful (0 votes)
15 views3 pages

Session-14-How To Log Into Snowsql

snow flake notes

Uploaded by

bhaskar1082
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)
15 views3 pages

Session-14-How To Log Into Snowsql

snow flake notes

Uploaded by

bhaskar1082
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/ 3

STEP1: install snow sql for windows in your PC and once u instal and run this file

"snowsql-1.3.1-windows_x86_64'
IH56456.central-india.azure

snowsql -a <account_identifier> -u <username>

snowsql -a IH56456.central-india.azure -u bhaskar1082 -its Working

snowsql -a IH56456 -u bhaskar1082

once the setup is done you can now run SQL in command prompt

SELECT * FROM MYDB.PUBLIC.ORDERS_CLUSTER;--Millians of records

***********************************************************************************
******************************************************
//Run quereis
SELECT * FROM MYDB.PUBLIC.EMP;

//Use warehouse

USE WAREHOUSE SAPLE_WH;


USE DATABASE MYDB;
USE SCHEMA PUBLIC;
SELECT * FROM EMP;

//USER STAGE
//PUT your files in to user internal stage

C:\Users\DELL\Documents\Files

put file://C:\Users\DELL\Documents\Files\EMP.csv @~/staged;

put file://C:\Users\DELL\Documents\Files\EMP.csv @%emp_table;

list @~/staged;

-----------------------------------------------------------------------------------
-------------------------------------------------------------
//TABLE STAGE

//put your files in to table internal stage


put file://C:\Users\DELL\Documents\Files\scott_emp_table.csv @%scott_emp_table;

//Create scott_emp_table to load files from internal stages

create table scott_emp_table(


--empno number(4,0),
ename varchar2(10),
job varchar2(9),
mgr number(4,0),
hiredate date,
sal number(7,2),
comm number(7,2),
deptno number(2,0)
);
-----------------------------------------------------------------------------------
-------------------------------------------------------------
//NAMED STAGE

//Create a schema for named stages

CREATE SCHEMA IF NOT EXISTS MYDB.internal_stages;

//Create a named stage


CREATE OR REPLACE STAGE MYDB.internal_stages.named_dept_stage;
CREATE OR REPLACE STAGE MYDB.internal_stages.named_customer_stage;
CREATE OR REPLACE STAGE MYDB.internal_stages.named_order_stage;
CREATE OR REPLACE STAGE MYDB.internal_stages.named_product_stage;

//Create dept table to load files from internal stages


create table dept(
deptno number(2,0),
dname varchar2(14),
loc varchar2(13)

);

show stages in mydb.internal_stages;

//put your files into named internal stage


put file://C:\Users\DELL\Documents\Files\SCOTT_DEPT_DATA.csv
@mydb.internal_stages.named_dept_stage;

list @mydb.internal_stages.named_dept_stage;

//load all files data to the table


//copy all these files to table customer_data_table

//user stage
COPY INTO mydb.public.emp_table
FROM @~/staged/emp.csv
file_format = (type = csv field_delimiter = ',' skip_header = 1);

//table stage
COPY INTO mydb.public.scott_emp_table
FROM @%scott_emp_table/scott_emp_table.csv
file_format = (type = csv field_delimiter = ',' skip_header = 1);

//named internal stage


COPY INTO mydb.public.dept
FROM @mydb.internal_stages.named_dept_stage/scott_dept_data.csv
file_format = (type = csv field_delimiter = ',' skip_header = 1);
***********************************************************************************
******************************************************************

Example:
//user stage
//put your files into named internal stage
put file://C:\Users\DELL\Documents\Files\industry_sic_data_user.csv @~/staged;

COPY INTO MYDB.public.industry_sic_data_table


FROM @~/staged/industry_sic_data_user.csv
file_format = (type = csv field_delimiter = '|' skip_header = 1);
-----------------------------------------------------------------------------------
-------------------------------------------------------------------

//table stage

create table MYDB.public.industry_sic_data_table


(
SICCode number(5,0),
Description varchar(750)
);

//put your files into named internal stage


put file://C:\Users\DELL\Documents\Files\industry_sic_data_table.csv @
%industry_sic_data_table;

COPY INTO MYDB.public.industry_sic_data_table


FROM @%industry_sic_data_table/industry_sic_data_table.csv
file_format = (type = csv field_delimiter = '|' skip_header = 1);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
//named stage

//create a schema for internal_stages


create schema if not exists mydb.internal_stages;

//create a named stage


CREATE OR REPLACE STAGE mydb.internal_stages.named_industry_sic_stage

//put your files into named internal stage


put file://C:\Users\DELL\Documents\Files\industry_sic_data_named.csv
@mydb.internal_stages.named_industry_sic_stage;

COPY INTO MYDB.public.industry_sic_data_table


FROM @mydb.internal_stages.named_industry_sic_stage/industry_sic_data_named.csv
file_format = (type = csv field_delimiter = '|' skip_header = 1);
*************************************************************************End*******
*******************************************************************

You might also like