Redshift Pivot and Unpivot Table-Transpose Redshift Table

In the relational database, Pivot used to convert rows to columns and vice versa. Many relational databases support pivot function. Recently, Amazon Redshift started supporting PIVOT and UNPIVOT function. However, as an alternative method, you can use CASE or DECODE to convert rows to columns, or columns to rows. In this article, we will check Redshift pivot and unpivot table methods to convert rows to columns and vice versa. Post Content Introduction Pivot Tables in Redshift Redshift Transpose Rows to Column using Pivot Example Unpivot Tables in Redshift Redshift Transpose…

Continue ReadingRedshift Pivot and Unpivot Table-Transpose Redshift Table
Comments Off on Redshift Pivot and Unpivot Table-Transpose Redshift Table

Redshift Reuse Computed column – Derived Column

Redshift Derived columns are columns that are derived from the previously computed columns in same SELECT statement. Derived columns or computed columns are virtual columns that are not physically stored in the table. Their values are re-calculated every time they are referenced in a query. Many PostgreSQL relational databases such as Netezza supports reuse of the calculated column within the same SELECT statement but Amazon Redshift does not support reuse of calculated derived columns. In this article, we will identify the alternate methods that you can use. What are derived…

Continue ReadingRedshift Reuse Computed column – Derived Column
Comments Off on Redshift Reuse Computed column – Derived Column

Optimize Redshift Table Design to Improve Performance

The performance of the Redshift database is directly proportional to the optimal table design in your database. Optimizing Amazon Redshift table structure is very important aspect to speed up your data loading and unloading process. In this article, we will check out some tricks to optimize Redshift table design to improve performance. Optimize Redshift Table Design There is no specific set of rules to optimize Redshift table structure. Creating optimal table design is based on the type of data that you are about to load. However, here are some of…

Continue ReadingOptimize Redshift Table Design to Improve Performance
Comments Off on Optimize Redshift Table Design to Improve Performance

Amazon Redshift Identify and Kill Table Locks

When you work on large enterprise data warehouse, you will be working with multiple tables and those tables will be shared across multiple data marts within your application. Sometimes, users will explicitly lock the access to the table if they are refreshing or updating data. In this article, we will check how to identify and kill Redshift Table locks. Redshift Identify and Kill Table Locks You can use Redshift system tables to identify the table locks. One such table is STV_LOCKS, this table holds details about locks on tables in…

Continue ReadingAmazon Redshift Identify and Kill Table Locks
Comments Off on Amazon Redshift Identify and Kill Table Locks

Amazon Redshift Derived Tables and Examples

When you work in an enterprise data warehouse (EDW), you will work with multiple data sources. Sometimes you may have to derive the table to get only required columns instead of joining big table. This process not only improve the performance, but also avoid unnecessary memory usage. In this article, we will check how to improve the performance of Redshift query by creating derived tables with some examples. Amazon Redshift Derived Tables In the real world scenario, you may derive the some column from base table and instead of creating…

Continue ReadingAmazon Redshift Derived Tables and Examples
Comments Off on Amazon Redshift Derived Tables and Examples

How to Find Redshift Table Size? – Examples

Amazon Redshift is a fully managed, distributed relational database on the AWS cloud. Hardware's are completely managed by the Amazon and to make database administrator life easy, it has bundled with many system tables. Those system tables hold abundant information about your database, tables, rows, statistics and many more. You can use these system tables to find Redshift table size without giving a second thought. How to Find Redshift Table Size? When you create a table in Redshift database, the table does not consume any space on the data slices…

Continue ReadingHow to Find Redshift Table Size? – Examples
Comments Off on How to Find Redshift Table Size? – Examples

Redshift DECODE Function Syntax and Examples

Amazon Redshift supports the DECODE function and it is similar to DECODE function in other relational databases such as Oracle, SQL Server, MySQL, Netezza, etc. You can use the Redshift DECODE function to implement the simple CASE conditional statement or an if-then-else statement. This command is a shorthand form of the Redshift CASE Conditional function. Redshift DECODE Function A DECODE expression in Redshift replaces a specific value with either another specific value or a default value, depending on the result of an equality condition. The DECODE function operation is equivalent…

Continue ReadingRedshift DECODE Function Syntax and Examples
Comments Off on Redshift DECODE Function Syntax and Examples

Generate Redshift DDL using System Tables

Amazon Redshift is a fully managed, distributed relational database on the AWS cloud. Amazon will manage the hardware's and your only task is to manage databases that you create as a result of your project. In this article, we will check one of the administrator tasks, generate Redshift view or table DDL using System Tables. Generate Redshift DDL using System Tables Amazon Redshift support many system tables, that will make your life easier as a database administrator. All the activity information's such as executed query, DDL, memory information, etc. are…

Continue ReadingGenerate Redshift DDL using System Tables
Comments Off on Generate Redshift DDL using System Tables

Redshift Split Delimited Fields into Table Records and Examples

Amazon Redshift is relatively new to relational databases. It is based on PostgreSQL, but being a columnar distributed database, it does not support all functions that are available in PostgreSQl. One of such requirement is split a delimited string into rows. In this article, we will check how to split delimited fields into table records or rows using Redshift built in function. Not that, the method described in this article usually works when you have a fixed number of delimited fields in your input string. Say, you have 5 delimited…

Continue ReadingRedshift Split Delimited Fields into Table Records and Examples
Comments Off on Redshift Split Delimited Fields into Table Records and Examples

Amazon Redshift DUAL Table Alternative

Amazon Redshift like most of the PostgreSQL relation databases like Netezza or Vertica does not provide support for dual system table. You can simply use the SELECT clause with nothing to display the results. In this article, we will check what is Amazon Redshift dual table alternative and how to use it. What is DUAL table? The DUAL is special one row, one column table present by default in databases. The database like, oracle automatically create dual table and grant SELECT access to all users by default. The dual table…

Continue ReadingAmazon Redshift DUAL Table Alternative
Comments Off on Amazon Redshift DUAL Table Alternative