How to Drop Single or Multiple Columns from Table by using Kusto Query | Kusto Query Tutorial (KQL)

Topic: How to Drop Single or Multiple Columns from Table by Using Kusto Query Language.


How to drop single or multiple columns from the table by using Kusto Query | Kusto Query Language Tutorial (KQL) Kusto Query Language is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more. The query uses schema entities that are organized in a hierarchy similar to SQL's: databases, tables, and columns. A Kusto query is a read-only request to process data and return results. The request is stated in plain text, using a data-flow model that is easy to read, author, and automate. Kusto queries are made of one or more query statements.

 How to drop single or multiple Columns from a table by using Kusto  
 //.drop column  
 //This command does not physically delete the data, and does not reduce   
 //the cost of storage for data that was already ingested.  
   
 //This command is irreversible. All data in the column that is removed will no longer be queryable.  
 // Future commands to add that column back will not be able to restore the data.  
   
 //Let's create sampel table TotalSale and insert some data.  
 .drop table TotalSale  
 .create table TotalSale (  
   id: int   
   ,SalePersonFName: string  
   ,SalePersonLName : string  
   ,ProductName : string  
   ,ItemsSold : int  
   ,SoldPrice :real  
   ,SoldDate: date  
   ,City : string  
   ,State : string  
   ,Country : string  
   ,Region : string  
   )  
        
      //Insert data  
       .ingest inline into table TotalSale <|  
 11,Tamara,Tony,Cell Phone,2,1200.50,2015-03-03,Frankfurt,Hesse,Germany,Europe  
 9,Petra,Henry,TV,10,5000.89,2015-04-08,Paris,Île-de-France,France,Europe  
 3,Christy,Ladson,TV,3,1600,2015-04-02,High Point,NC,USA,North America  
 7,Chirag,Patel,Cell Phone,5,1500,2015-06-23,AhmadAbad,Gujrat,India,Asia  
   
 //Check the data in table  
 TotalSale  
   
 // Let's say we want to drop column Region  
 //Syntax : .drop column TableName . ColumnName  
 .drop column TotalSale.Region  
   
 //Check the data in table  
 TotalSale  
   
 //If you want to drop multiple columns  
 .drop table TotalSale columns (City,State,Country)  
   

Video Demo: How to Drop Single or Multiple Columns from Table by using Kusto Query Language


No comments:

Post a Comment