sf
sf
Stage area: An itermediate stage and space in cloud to the files before loading
into target environment
so staging area is in betweeen files souce to destination.A tempararory space
adrea to load and unload the files.We cant load the files in to cloud. before we
can load we need to load the files in to Stage area.
Types of Stages:
mycsv is thefile
fileformat
list @~;
put file ://D:\Movies\Snowflake/Testfile.Csv @~;
copy into STUDENT from @~
files =("Testfile.Csv.gz")
file_format = (format_name=Mycsv);
Table Stage: Space provided by SF can use every table. any one can use tthat table
space.
it is denoted with @%table name
ex:@%student
list @%student;
put file://file location/ @%student
copy into student from @%student
files =('file2.csv.gz')
file_format = (file-name =My_pipe)
list @%student;
put file://file location/ @%student
copy into student from @%student
files =('file2.csv.gz')
file_format = (file-name =My_pipe)
Purge=True
purge is used to remove the files from (files we wants) staging area after
succesfully loadidng into table
--> Named Stage: by using named stage one user can create stage another user can
use that stage area and any one can use and create the tables in named stage.
put file://<file1location>/@local-stage
put file://<file2location>/@local-stage
put file://<file3location>/@local-stage
putfile://<file4location>/@local-stage
files =('file1.csv,file2.csv,file3.csv,file4.csv')
file_format =(file_name= mycsv)
But this is not best practice to load multiple files. So we can use PATTERN
--> If the file format has difftrent types of formats then while loading we get
error. to avoid this we can use on-error
Ex: I have 100 files in that 99 files are csv and 1 is pipe.. in that cenario if i
load 100 files i get error so to acheive this
-->To load the same data again and again we can use force.so it didnt check
irrespective of data loaded previously or not it will load the data again and again
list @extstage
copy into student from @extstage
pattern = 'file1.csv'
file-format =(file-name=my csv)
on-error = skip-file
how many times files will uploadedin sf and failed to upload by below command
Show Pipes
Micro partition: to store the data in tables sf it self will devide in to small
parts called mico partition
it is columnar format
every micro partition consist of 50 to 500mb
it stores the meta data(data about data) like range of each column
Clustering:
Re Clustering:
Re clustering is used to cluster the already clustered table.
it is used when new values are updated in cluster table we can use re clustering
Cloaning:
The main purpose of cloaning is at a time many users can do process the data on
single table
with out cloaning it will impact on other user like if A is user updating Table
called Test at the same time user B is deleting some files table Test. it will get
work disturbance to each user
Zero Cloaning: In Zero cloaning it will copy only structure of Master table.
it wont copy the data present in Master table
it will create a link which is pointing to the MP in Master table
If any DML operations(Insert, Update, Delete, Create) are done it will create New
MP in cloned tables (Data will update in Cloned tables only not in Master Table)
If any old data is there it will read from Master table.
How To Clone:
if we clone the schema it will created cloned objectes for all the tables under
that Schema
Time Travel:
if by mistake any data has lost or corrupted we can get the data by using time
travel
1) TimeStamp
2)Offset
3) Quiry id
AGGfunctions is table
Types of Tables:
1) Physical table: this is the table in genrally using normal day to day
activities. this table consist TT 90 days and FS 7 days
2) Temporary Table: This is the table we can create only for Temp0rary purpuse.
This table consist of 1 day TT and 0 FS
It is Session Dependable. Once session is closed table
autometically dropped off. If we retrive the data untill session has been closed
only.
Never give same name to Temporary table which as already name given to physical
table bcs sf will give more priority to the Temp Table.
3) Transient Table: Table which is similar to Physical table only diff is no fail
safe
4) External Table: which can access the external files as table. it doesnt have TT
and FS bcs it is not loading the table data it just reading the data from table
Viwes: View is nothing but Logical representation of table. It wont store the data
Physically.
it is similar to the table the main diff is it wont store the data
1) Doctor_view
2)Accounts_view
2)Accounts_view
So wehave devided Hospital data in to 2 loical tables which are using respective
sections.
Types Of Views:
2)Materialized View: it is similar to the table it can store the data physically