Transcript for:
Snowflake: Managing Tables and Data Retention

okay we'll see one thing okay now we are how can you display list of tables tell me in one how can let's pay list of tables in a particular database where's image keyword s okay so we'll give you a list of tables okay so after one second and second will work for other database so how can I I want to get like this okay so this name how to get so I want to get August everybody and tell me how can I get it I want to get okay instead of this thing I want to get August 11 scheme how to get wise image Concepts serious sector worksheet context so that it will be like this okay now show tables so this one how many tables are there okay there are ten table version okay so 10 tables okay now suppose okay this is my main table assume like this is my main level now question is that what in this 10 tables I want to figure out figure out which is main table and which are true on the table anybody can ever tell a where you can able to figure out important recently this question is asking tell me I want video which is main devices which is the Clone table where we can able to get go back here okay Services remember in Snowflake 10 15 topics like one or two out of silver out of like okay like uh like real attention as well storage metrics okay so now I want to get this database how to get this database by using query by using selected tell me thank you tell me selected how to get this database name I want to get this database name under schema tell me how can this later name select current ly database okay so current is current you know okay okay now I want to Club these two things how can I Club these two things tell me questions now tell me I want to take this value and I want to get the output like this okay now I want to do this column as a filtering column okay see one more time I'll tell okay see there are so many databases are there my requirement is that what I want to get on the studio DB obviously okay so I want to get this output to be concurred how to do and what you can never tell them so I want to get filter my one database foreign foreign database I have this thing like this okay I want to get okay I want to pause here and I want to get the output to be done okay okay see if I put my little throw it won't give any records my requirements said what okay I want to pass this value and I want to get the output same like August like I want to get a list of tables in this particular ODB okay say I15 is this 10 records how to fight system that's what happened so see I have done like this okay if I put it is not working okay what I need to do a simple thing I'll give you one second tell me what I need to I'll tell you not enter simple thing okay this is what tell me this is what model of things obviously we always think database concatenate table schema okay separate columns table schema this is now tell me this one what okay how can I say like okay this is clone table and this is normal table where you can never triggered by the image concept figure out ID and clone group ID both are same that is the main table main table okay now requirement suppose here how many tables are total tell me how to find total number of Records so count up start your total number my requirement is that what I want to get which is which is clone table and which is amazing each concept N1 and ID entity now my recurrence supposedly 10 days so 10 tables are there suppose like six tables are base table four tables are round tables I want to get output so ten tables came now how to get 60 over 6 tables and how to get four tables now conditions purpose you should go forward concept conditional purpose this is the same thing now what happened okay now see so ID so this is one one okay so this is zero now how can you do addition how can radiation basing its function cannabis addition some some positions so okay sum up it will give what it'll go same thing okay now this is very much some out of the same thing okay so this is whatever this is what this is base tables based okay now how to find normal table how to find normal table how to find clone table what we do it extracting what to put instead of equal to is not equal to that table now how to get the best how to get total records how to get a liquid simply counter child U to total number of total tables so this is what see like upgrade function column is all the constices I suggested so 10 records out of ten nine records are vegetable one record is a long table clear up so like you say you should understand okay so clear foreign so go here and try to create one type I'm trying to create one table customer details table now what happened I am trying to insert one record okay second record and third record now go back here now put select the star from this table what we'll get and get out three regards okay so take the screenshot okay all right that's not what I'm going to do is go back here okay now this is my table suppose like suppose like Ram is there he wants to he he got traffic from Pune to Pune to Delhi okay how can I do it how can I modify existing currency the broad concept visible concept update update statement okay update table name okay set what set City equals to L he okay where customer ID customer ID equals to three okay now what happened by mistakenly one unit developer is that what happened okay instead of putting this rare condition you directly operated how many cards you get updated roll back and I go for rollback to work no it won't work because uh DM models are hard to commit instead of like DMS are autocracy there won't be any impact see what happens okay see okay see it is there okay tell me same thing if I turn in production tell me is correct in production it is a word it's a big excellation travel it enables it enables accessing historical data historical data within that within X specified period of time and we'll see what this is important so what is a data retention time so retention time is nothing but what okay how long we are asking snowflake to preserve the data this is so your screen is half visible and half not visible like from time travel it's hidden can you zoom out a little bit maybe okay because right now what's the data we're having in the database right now what we are having modify data this is the latest data this is the historical data now how can you access this historical data we will go for what we'll go for time travel it is nothing but it enables accessing historical data within a specified period of time so specific various nothing but say data retention time how long you're asking the snow effect to preserve the data that is a data reduction getting a little bit at least so go back here and see the same thing I will get like but end of this class okay can I will get some data what exactly thing as I see so our requirement is that what okay our requirement is to get this data okay how can I get will go for okay we are having one from there is so time travel okay so time travel see one more time one more time now before that what happened whenever you see X good anything now see if exit will not happen what happened a query ID will be generated series okay in a similar fashion X will one more time same thing what happen see now try to export seriously okay so see the same thing now what happened tell me so both are similar both are different so whenever we execute any statement snowflake generated one query ID and as well as one session session now tell me this is what session this is my current session you see current session okay so these are important I can see okay this is new session you see okay okay so one more time now what happened okay now this is my whenever performing now snowflake is related one query ID now what happened we'll try to create one more time okay see table has been created yes the table has been now what happened okay see the same thing now try to create this table okay see the same thing no table has been created now what is it for everything a query click on this copy this query and pasture okay see you get to know what exactly in a similar fashion try to exude statement a query ID will be generated and paste here in a similar fashion try to execute now what happened a query ID will be generated so this is the query area now what happens what I said for each and everything what snowflake is generated one query ID okay now what I want to go back here now see now when X would know what happened here it is okay so we'll put one more time so try to Exodus table is a different table so try to take this copy query ID yeah so like you put the wrong table okay in a similar fashion so put one put one now try to exit one more time copy this quick what we are trying now you'll get to know what we are trying to go back here so put here same thing try to execute and then copy the query heading you see so this is no what is the table lamp so this is my table name how many cars in there we are having three records so take the screen one more time you'll get some money okay that's same okay okay now what I want to say knows this is the latest data so what happens some okay by mistake only one Junior developer is there what happened instead of one record here all recursive what happened now what happens see that you can see the data what happened so of this query ID go back here now try to see okay so there's so many questions remember this topic is very very important so many questions will be asked this question as well okay see now so these three requires when I go here what happened okay instead of one record all the requires it now what is this is the latest data now once I want to get the historical data how can you get a historical data I will go for time travel concept yeah so go back here copy the same thing okay so it will give what it will go the latest data but I want to get the okay historical bit then we'll go for one keyword before now now tell me which data you want to get what is the data what is the original data which is the original data until menu what's the original data um city name different one no before no before updating we this is our version address now this is my original data when is the original Data before update statement I want to get the data then what happened before statement okay before statement before statement okay so this is a Syndicate we should use the query I okay so select star from table name so table name so before statement and which parts are query ID now what's the table name table name is what our table name is for customer details and what is the statement okay so this is a table what's the query ID so this is my query okay of this query ID and paste here tell me you got a letter instead of getting in yes getting no okay see so before the statement we are trying to getting there okay so this concept okay give one second and one second okay see now what happened see now select start from customer details so now this is the data tell me so we can able to get a decade and now I want to create a table you can able to create so create one status table so this is we can able to create table something like okay backup table so I can able to get the data okay get an appointment so see like this we can never get here now you got the issue issues that what by me secondly one snowflake developer is there instead of one record we are better now how can you get the data we can able to go back and travel and we can able to access this time until something but what enabling historical data at the particular period of time circulator is nothing but what okay somebody change somebody trying to get it somebody deleted and you can able to get the data back clear a circle and you're getting a little bit at least yes or no so there's so many questions will be asked in this truncate table the table name okay now see the same thing now I did not copy the query at 10 then how can I get the quality so I did not copy the query again I will get the queries so we should go further it is now responsible to copy every time the query is okay so go back here go to the activity okay there we can able to get a list of this okay so let's start queries okay now what is the requirement so we should go to before the statement okay copy this query ID go back to the worksheets okay so to the current session now what happened now what's the square root is we should use we should use before keyword again so before the statement I want to get the data statement okay I want to get the data suppose we put what will happen tell me if I put at will get the rate or not we put that at the butler tough time what happened there won't be any data because we have trunk data in this pattern okay so before this statement I want to get the date I will offer like this getting a liquid at least what happened snowflake no for each anything what happened a query it is it will be stored this is nothing but time travel for each ending there today keep on tracking all those things okay later so far snow now tell me I want to populate this data this particular table okay this data whatever data recover data I want to cooperate in the snow is stable anybody can tell me what kind of properties data yes okay see my requirements have got this data so whatever data we're getting on this data I want to copy it is how to do how can insert data clones clone at the same night same data is just I want to dump and dump this data into this table with three records I want to take and I want to put into this table anybody simple thing using something no no seat is we need to go for separate table okay I don't want to go to a separate table I want to get the same thing tell me simple insert into director statement insert into this is a selection so okay so see so we have selected data and we are trying to so we are selecting theater and try to insert it to same table so see relative list so like this okay so this these are important I guess a simple thing but you are not able to see we are selecting this data and we are Titans in the same table because same this is because the same columns and same column we can able to go directly again list is now select the station without giving the insert Wireless how can I get those uh come again without inserting values how can we get those values on those records without answering conditions like what we want separate table support table will go for CTS no because not getting version but without exciting means we need to give Wireless now you want okay um suppose you see I am going for is stable now instead of stamina I'll go for only customer ID customer okay I can go for customer so you can suppose like if you want only two columns only one column you can go for Testimony to see clearly cuts when I go for this statement like this this is one more syntax so go back here see only customer is getting popular remaining we are getting null values for data okay so suppose we'll go for one more is here so take the same thing suppose selected one ravine something like TP this data I want to populate in this pattern table simply what okay we have three columns now in this one how many tables okay so simply we can take and we can able to populate the data see one recurrency so this is one one way of inserting the data okay so let us open so see where you can applicate all these query it is we can go that has been change okay are modified okay or deleted or dropped then we'll go forward we'll go for like response okay so we go for our model skills so we close this thing okay so there's so many questions okay so this is important okay so go back here now try to open worksheets okay now try to create okay now go back here now try to create one table one multiple create table something like now I'm trying to insert into EMP one two three values okay now what happens then copy this query edit and paste here okay without any suggestions next question is next one is that what suppose I okay now tell me before the statement I want to get this set how can I get we'll go for selected so remember select start from table view latest data latest data okay now what happened now I want to get before the statement what is my data statement so this important statement okay so questions so before the statement what's going to tell me before the statement what data will be there N1 before the statement aggregation what is the data okay suppose when I put can you tell me at this product of time what will get only one record no so far noises no what happened I have drop table EMA one two three okay now this is also one query so don't tell me now I want to get this data tell me this time travel worker statement worker any idea thank you um we can undraft the table now let's see what happens when I tell you what happened okay okay see so object employee 2003 does not existence like what there is no object okay this is fine so what about we see time travel you cannot try to exclude what is saying because when you want to exist select statement mode composite is a stable result but what happened we heard we have to draw this table now how can I Rectify this issue I want to get the data then we should go for which keyword which keyword table table name this is one of the snowflake feature okay so Roundup is also one of the time travel okay now go back here now see the return we can able to get the data later yes okay so when you want to get the statement oh yes go ahead so with undrop we'll get the table back no this one it is so only at the current session or it will we can make it interesting okay we'll see okay okay we have time tables try to drop this table go forward session foreign so this is ID number okay see by default when you create create table it's not say by default by default it's a ferment table this is a permanent table okay apartment table okay so if your Journal can work right okay in a similar fashion now instead of time table you should trans ZN okay we'll put the transient keywords in transient table so transient okay so transient okay so take the same thing now we can go for temporary we should put either Temper Temper we put Tempo temperature so see the same thing okay go back here now try to execute now what happened table has been Circuit by defaults whatever it say fermentable see what exactly this is transientable it is a temperatible okay tell me how can I see list of tables organization list of tables okay so by the short tables we can never get the list of tables okay so put SCB okay what is concept filter filtering is fine what is the exact why are you getting one ACP data all right anyone pattern matching you will discuss the pattern matching pattern matching like yes sir okay so pattern matching series blue like this okay now see the same thing now so see September permanent is what you say permanent table this is temperatible this is transient table getting the points so see so we can in Snowflake there are three types of three set of tables but permanent table transient table and temporary tables okay so by default see what happens Say by default it's in permanent foreign data retention time editor okay so remember by default by default for all the tables types okay it is what anyone knows what is redirection name is 0 to 90 days zero two not right okay see so for all the tables you see default is what zero default is one only see this is suppose if I exclude one query okay so this query we can able to execute for one day one day okay same tool we can able to explore for one day again that is nothing but what so detention time so data Regional sub Network how long you can able to access the historical data is one day up to one day we can able to access the same query same Perfection so see this is by default for all the table one day so see suppose okay which is the difference between transient temporary environment okay so it's a default default the equivalent setting okay so we should explicitly mention transient and temporary now I want to increase this time Travel how can increase the sample cover holder table table name is set data attention time okay we will after this and see now we get an okay reduction time it is equals to 2. so what happened now I want to increase from one day so I want to preserve this data for two days okay so see take the same thing copy the same thing now try towards the table name table name is what now what happened from C it is getting from one day two it will go back here try to see the sap okay so you go back here now see what happened okay now from one day it's increasing to two days now what happened I connect this to 90 days okay see 90 days okay it's taking 90 days go back here that's what it should be 90 days so this is important okay so come back go back here so see it is 90 days okay now 90 days okay now I won't put from 91 what happened it will throw error okay so reason is so reason is that word so for permanent tables it will be 0 to 90 days we can able to have the time this is like what up to nine days you can able to ask snowflake to preserve the historical data okay so same query can I will exit of nine days the same battle it's not but time travel getting the person required at least so it will be 0 to 90 days okay what about transient table so go back here and see whether it is working fine or not so see go back here come back English then see one day okay you see now what happened now transient table one day no issues now we'll put two days it is so see it won't work in a sense like what so what is the what is the default detection time it will be one so zero to one day okay like this you should practice this is a compulsory questions okay for into perspective your time also this type of table so insist only what when where situations so this is zero to one day go back here go for temporary table okay so go back here now try to see the temporary table now try to execute now zero so zero is nothing but what anybody tell me what is zero what we are asking zero is nothing but what no disabling temporal so when you put zero instance like what okay we will disabling that we'll see what exactly we are disabling the time travel okay in a sense like what we can able we can't able to explain this directly we'll see what exactly so put the same thing it is working fine so put two so go back here now what's the conclusion so see it is 0 to 0 to 0 to 1 day okay see so by default for all this type of tables okay these are snowflake internal tables apartment table transient tables temper tables for this all three types of previous word okay so default is one now what happened I can able to take this to zero to nine days zero to one is okay now see these two tables now both are same so see zero to one zero to one Okay now what's the difference both are same one what's the difference go back here now we are in which station see this is current station okay how to session how to get the current station will go from selected current session if you see this thing Okay now what's the value rating creating the values so see four seven two zero six okay this is my current session copy the same thing go back here now try to search for the same session you see foreign search here and try to execute okay so what happened to see save okay okay how many cards can tell me two records which card is missing one second you said session specific in the sense like what only it will be available for the particular you see sign out now see how many days one more time I'm trying to see how many card scheme send a sense like what once you log out the session what happened the table get automatically dropped again little bit at least okay see what happened so temperate tables are session specific tables active level for only fertilization once you log out of session what happened certain will get automatically interrupt getting the production yes or no yes no okay see by default okay see by default so for all the types of table data connection time will be one day if you want to increase me we'll go for alter okay so see what happened okay we'll go for one more time so I'll put okay employee ID one okay employee one I am putting data retention in the starting time also you can enable Google detection time in this equal to zero so what I'm trying to do I'm trying to disable the time travel okay so this is one table and this is okay but the time travel okay so okay without without a time travel and with adapter you see the difference you see this is without time travel again this is with the driver driver okay now so drop table so this top table same thing drop table this table again so the store two tables I'm trying it okay now first table dropping second table also dropping now tell me if I put undrop it will work or not anybody or not for the first table it will work it will not work reason what what happened we'll get so it does not exist or it can be part in the sense like what okay so because now what we are trying to disable work see we are asking data tension time equal zero distance required to expressly ask don't preserve the data it will be there okay now what happened what about the state and see we are trying to undrop so it's working fine because so this is having time also up to one day we can able to bring the data okay suppose I want to bring this data okay is there any optional I want to bring this data tell me is there an optional so we have a desert time hypnosis but what happened is there an option apart from time apart from okay and drop is there any feature yeah we need to change the table name already then how can I change application previous guys okay second time listening tell me how to get another other concept we are having another concept what is our concept then time travels what data where it restore if you go to where yeah see what happened okay remember so see okay important Point okay so what happens saying we are we are disabling the time travel okay so this is a prime driver okay now what happened data will be moved to the data will be moved to the is is available available okay now what happened what I am trying to say okay go back here now what happened now suppose like or take employee table it is having one day one day now what happens supposing 20 20 48 okay today 248 this is today's word September too well okay tomorrow What happened tomorrow September 13th okay I came here and I want to get this query tell me it is not because it is it is well for only one day now also want to bring data what happened okay now data will be moved to the data will be more to the sales so fails if it's or what it will be there for only permanent tables that two loss for it will last for seven days one more time so see permanent tables what it will go for 90 days if you want to get any ads less you should go forward so up to seven days no when the failed separation getting a little bit no let us offer getting a little bit at least Okay so so if we have uh Define the time limit as one then it will be plus seven days for Fields yes so whatever we have decided like if we have decided one then plus seven days so this is not in our control see no user operations allowed okay so data required only by snowflake one more time this is very important okay so this field shape is not is not in our control is not in our control okay this is what this is managed by this is fully minus by by whom by snowflake only snowflake okay so we need to raise that is separate ticket to snowflake to bring the data back okay more on things see what happened what is saying excuse me no user operation alert digital record only by snowflake innocent so we can't remember one thing we can enable accountable disabler we will say because so by default once time travels now automatically data will go to free data is more to the what go to the fill safe region feels it is not inner controller you see this is no user operational remember in real time we don't do this again because now we need to write separate because no because 90 days to record this okay okay like this clear Surfer so see what happens snowflake time travels enables accessing historical data modified or drop or objects can be reached or see suppose like by mistakenly deleted it so data suppose okay yesterday okay see what happened I want to if you want to compare yesterday's data data with today's data then how can I compare simply how can I compare me we'll go forward we'll go for time travel take the query ID and we can able to compare it these are the important so data duplication suppose we want to take a backup table you cannot go over one more time so see why we want her we will go for something visible something happened we want to restore so we want to compare the data we want to get the data duplication again okay so if we put selection of material from the currency one standard now it will go to the default mechanism one more time so go back here second so these questions will be like they'll ask okay like okay I see so by default when you create what table what happens if I say permanent table we should mention explicit transient temperature table now tell me table will be dropped up permanently automatically permanent tables and transient table no okay see temporary tables only get automatically dropped when you close the session see so we need to put explicitly drop table table in drop table but what happened once Equalization automatically this temporary table idiot it will get X it will get dropped again so time will be 0 9 is 0 to 1 is 0. so fails available only permanent tables it will be 0 days so data is into all the users all the users whatever is going to tell me whatever you tell me it will be for the current user okay see because this system specific tables Asana getting the points a little bit yes no piano okay see we'll see some enter questions okay so many questions will be asked on this table okay so you go back here now tell me time server which type of tables which type of tables foreign okay will time travel and creative contribute or not yes yes this data so this way never know why you are getting data because some ways it is storing snowflake story so if storing is like what snowflake they will charge the customer see will time travel and place a control they need to pay what is the option tell me a important point okay so see which type of tables do not have fails if temper which type of tables temporary transference okay sometimes they don't ask directly they lost like this okay I have an existing employee table with the data now I am going to convey the employee table and see one more time this is slowly okay now understand the concept saying mute yourself thank you okay so go back here so I'll try to sim for this use case okay I'm having employee table it is having 10 required server okay yes or no okay okay see this one tell me what is the philosopher of transient table seven days zero seven days zero zero zero so for Trans and table there won't be fails okay how to disable the time Tower of a table letter attention time and days equal to zero innocence report it will be disabled then what happens foreign will come again please ask again no what happened now now see this is same table employee table employee table okay no I am trying to create one more table with one decent column I remember now what happened what is the data over there in employee table the table so see what happens go back here so this is important suppose I created one table okay so this is like this only the question should be there okay so they're not asking straightforward questions so this is the MVP okay this is my table so data connection I got up to one day we can able to flow insert into EMP again see values values and I'm going for one okay see one okay go take the same thing of the query ID now what happened so C1 okay now take the same thing now what happened I'm trying to create with the same table creator replace okay so this is same level supposedly I'm putting here you see table has been okay now when I put select start from what will happen tell me select start from data will come and write on them anyone it won't come soon because it says right now what what happened create a replacement existing tab we are trying to drop and we're trying to create a drop down then there won't be any data now what's the requirement I want to get this data suppose I will go for before statement okay till mid worker now table is different how it will work okay see the same thing so see the same thing so see time travel is not available only one name should be given for only one object but what happened tell me so this already it is there then what happened first we should rename this table how can I rename alter table table name rename two different table okay now try to undraft okay so that word will get the one record getting the points understand what we should know this concept what are the concept so see so in database only one name should be given per only one objects that's about we are trying to rename the existing object so that we can able to get the data back foreign see one more time how many types of tables you're having temper permanent table transcendants temporary table transcendable under temporary table at this number okay so like this occasion so by default the permanent table we should mention exclusive transient temporary so temporary session specific table so once we log out the session we'll be in automatically dropped okay so we need to drop this table manual crop table table okay it will be 0 to 90 days and zero two this is zero to one day zero to one day suppose I want to get I don't want fail safe okay and then we'll go for about temporary or transition s okay we'll see this use case once is a loaded loading part okay which type of table will go from like this 10.1 so prepared okay nobody is asking foreign so these are like okay like okay so because we are going for experience okay we put experience we should go all this is a permanently prepare the knows like this way okay this is easy and clearly okay so once you go to Windows simple we can even see we can never sing okay so whatever discussing this is a bit CDP concept okay continuous data protection so we want to protect data why what product data because it's a business Data Business data we want business but CDP continuous data production protection okay same thing see what happened okay same use case okay okay now see one table created inserted selected drop is the same table inside of different columns incident drop so create with different columns instead of drop okay now if you put under which they will get which they will get under what's the table will get saved again challenge delegate latest but if you want to get this table what should do what we should do we need to renames the latest table so we're going to rename them see what happened is stable we should rename with this table so again suppose you wonder we should rename this table with different name for the point up so instead of this right foreign excuse me sir nice go ahead so for uh this one we need to rename this the the current one the current table so this table okay so what's what the completions that were in database one object one name should be given for only one object okay when I try to unlock now what happened in the history whatever these two tables but what happened when I try to unwrap table tape no this table is already there then how can I get okay we should rename this existing with different name okay so that one we can able to under this table suppose it's stable solved then what happened we should rename this different level so that we'll get this logic is that word in database one name should be given for only one object okay that's the point okay if you want to get data we should we should what we should and we should rename the exist table and we can able to under suppose we drop underneath it the same day what we want to under this table so we rename this existable so that we can able to undock the previous