How use Lateral Column Alias in Redshift?

Redshift lateral column alias, also known as derived column, is created from previously computed columns in the same SELECT statement. These columns are virtual and not stored in the table; their values are recalculated each time they are used in a query. Many PostgreSQL databases, like Netezza, support lateral column aliases. Recently, Redshift has also started supporting this feature. In this post, let’s explore this new capability. Page Content Introduction Benefits of Using Lateral Column Alias in Redshift How Lateral Column Alias Works in Redshift (with Example) Lateral Column Alias…

Comments Off on How use Lateral Column Alias in Redshift?

Redshift Pivot and Unpivot Functions: A Comprehensive Guide

Pivot and unpivot are common functions in relational databases for converting rows to columns and vice versa. These function are supported by many relational databases, including Amazon Redshift, which has recently added support for PIVOT and UNPIVOT functions. However, other methods such as CASE or DECODE can be used as alternatives for converting rows to columns or columns to rows. In this article, we will explore the Redshift pivot and unpivot table functions in detail for transforming your data. Post Content Introduction Redshift Pivot and Unpivot Functions Pivot Tables in…

Comments Off on Redshift Pivot and Unpivot Functions: A Comprehensive Guide

Change Redshift Table Distribution: A Guide with Examples

Selecting an appropriate distribution style is a crucial factor in enhancing the efficiency of the Redshift Database. The distribution style you choose can have a direct impact on your query's performance. Using an incorrect distribution style for a table may adversely affect your Redshift cluster due to increased workload. This article will demonstrate how to change the distribution style of a Redshift table, along with an illustrative example. Page Content Introduction Redshift Table Distribution Styles Why to Change Redshift Table Distribution style? How to Change Redshift Table Distribution Style Changing…

Comments Off on Change Redshift Table Distribution: A Guide with Examples

What are Amazon Redshift Distribution Styles? – Examples

Amazon Redshift is one of the popular cloud-based data warehousing solution offered by Amazon Web Services (AWS). Amazon Redshift is a cluster of nodes with separate disks, memory and CPU. One of the important features of Amazon Redshift is the ability to choose from different distribution styles to manage the distribution of data and computation across nodes in a cluster. In this article, we'll discuss the different Amazon Redshift distribution styles and the best practices for choosing the right Redshift distribution style for your needs. Amazon Redshift Key Distribution Styles…

Comments Off on What are Amazon Redshift Distribution Styles? – Examples

How to Get Rows Affected by Last Snowflake SQL Query?

Databases such as Teradata (BTEQ), SQL Server, etc., allows you to get rows affected by the last DML statement using system variables. For example, ACTIVITY_COUNT in Teradata BTEQ. The row count of the last SQL query allows you to identify if there was any activity on table. Snowflake scripting provides system variables that hold the information of rows or records affected by an INSERT, UPDATE or DELETE queries in the current session. In this article, we will check how to get rows affected by last Snowflake SQL Query. How to Get Rows Affected…

Comments Off on How to Get Rows Affected by Last Snowflake SQL Query?

Dynamic SQL Queries in Snowflake Scripting

Dynamic SQL is one of the important features that many databases support. Dynamic SQL allows you to write SQL queries during runtime. With the help of dynamic SQL, you can build your SQL query on the fly and execute them. In the data warehouse, there may be a situation where you want to generate dynamic SQL queries based on your requirement. In this article, we will check how to use dynamic SQL queries in Snowflake scripting. Dynamic SQL Queries in Snowflake Scripting Dynamic SQL Queries in Snowflake Snowflake supports writing…

Comments Off on Dynamic SQL Queries in Snowflake Scripting

Working with Snowflake Scripting Stored Procedures

Writing stored procedure is one of the import method to encapsulate your business logic using procedural language. Snowflake does support writing a stored procedure using JavaScript and recently they started supporting SQL scripting much similar to Oracle PLSQL. In this article, we will check how to write Snowflake scripting stored procedures. We will also look into some examples. Snowflake Scripting Stored Procedures In general, Stored procedure combines the complex SQL business logic with procedural statements such as IF-ESLE, LOOP, etc. Snowflake Stored Procedures Overview Snowflake stored procedures are used to encapsulate…

Comments Off on Working with Snowflake Scripting Stored Procedures

How to Export Snowflake Table to S3 bucket using DBT?

As cloud data warehouses are gaining popularity, new tools are emerging to interact with them. One of such tool is a Data Built Tool (DBT). DBT is a data transformation tool that focuses on the Transformation part in ELT (Extract, Load, Transform) processes. It supports data warehouses such as Snowflake, Redshift, BigQuery, Databricks, etc. In this article, we will check how to export your Snowflake table to S3 bucket using dbt. What is DBT and How it Works? Before jumping into the approach on exporting Snowflake table to AWS S3…

Comments Off on How to Export Snowflake Table to S3 bucket using DBT?

How to use Redshift NOT NULL Constraint? Its Syntax

In my other Redshift related article, we have discussed how to define a primary key, Unique key and Foreign key constraint in Amazon Redshift. In this article, we will check how to use Redshift NOT NULL constraint with its syntax and examples. Redshift NOT NULL Constraint Similar to most of the MPP databases such as Snowflake, the Amazon Redshift database allows you to define constraints. The Redshift database does not enforce constraints like primary key, foreign key and unique key. But, it does enforce the NOT NULL constraint. Constraints other…

Comments Off on How to use Redshift NOT NULL Constraint? Its Syntax

How to use Redshift Foreign key Constraint? Its Syntax

In my other Redshift related article, we have discussed how to define a primary key NOT NULL and Unique key constraints in AWS Redshift. In this article, we will check how to use Redshift FOREIGN KEY constraint with its syntax and examples. Redshift Foreign Key Constraint Amazon AWS Redshift is an analytical columnar cloud database. It is mainly used for analyzing your data to create a key KPI to make critical business decisions. The Redshift cloud database is based on PostgreSQL 8.x and many transactional database features such as table…

Comments Off on How to use Redshift Foreign key Constraint? Its Syntax