Netezza Count All Database Objects – System Table Query

You may have to query few system tables to get information about system, for example, get list of all tables, views, system tables, synonyms, sequences, etc available in Netezza data warehouse appliance. Getting object details information will help you to identify and manage Netezza system better. You can identify the tables or view which are needs to be deleted or removed from Netezza server. Below are few queries that are consolidated to provide useful information: Netezza Count All Database Objects – Tables, Views, Synonyms, System Tables, Databases Below query provide…

Continue ReadingNetezza Count All Database Objects – System Table Query
Comments Off on Netezza Count All Database Objects – System Table Query

Export Redshift Table Data to Local CSV format

You can export the Redshift table in many ways. Redshift export table is done using either UNLOAD command, COPY command or PostgreSQL command. Using UNLOAD or COPY command is fasted way to export Redshift table, but with those commands you can unload table to S3 bucket. You have to use the PostgreSQL or psql to export Redshift table to local CSV format. Export Redshift Table Data to Local CSV format To export Redshift table to local directory, you must install the PostgreSQL in your machine. You can use the psql…

Continue ReadingExport Redshift Table Data to Local CSV format
Comments Off on Export Redshift Table Data to Local CSV format

Redshift Set Operators: UNION, EXCEPT/MINUS and INTERSECT

You can use the Redshift set operators to combine similar data sets from two or more SELECT statements. Here the similar data set literally mean, the data type of the result set should also match, otherwise you have to explicitly type cast data when using Redshift set operators. Types of Redshift Set Operators Redshift supports the three types of set operators: UNION [DISTINCT] and UNION ALL INTERSECT [DISTINCT] EXCEPT [DISTINCT] or MINUS [DISTINCT] Redshift Set Operators Syntax Below is the syntax of Set operators in Redshift: query { UNION […

Continue ReadingRedshift Set Operators: UNION, EXCEPT/MINUS and INTERSECT
Comments Off on Redshift Set Operators: UNION, EXCEPT/MINUS and INTERSECT

Redshift Regular Expression Functions and Examples

The Redshift regular expression functions identify precise patterns of characters in the given string and are useful for extracting string from the data and validation of the existing data, for example, validate date, range checks, checks for characters, and extract specific characters from the data. The regular expression functions allow you to perform complex string manipulations within Redshift SQL statements, such as searching for and extracting specific patterns, validating data, and replacing values. In this article, we will be checking some commonly used Redshift regular expressions with examples. Read: Amazon…

Continue ReadingRedshift Regular Expression Functions and Examples
Comments Off on Redshift Regular Expression Functions and Examples

Commonly used Redshift String Functions and Examples

Amazon Redshift String Functions are used for various string manipulations in your SQL queries. Redshift supports most of the standard SQL string function for your string analysis in Amazon Redshift. Redshift also provides the Redshift extension to the string manipulation functions. Redshift String Functions Amazon Redshift provides several string functions that allow you to manipulate and analyze character strings. These Amazon Redshift string processing techniques allow you to handle complex string manipulations. Following are some of the most commonly used string functions in Amazon Redshift: Redshift String FunctionDescriptionLEN(expression) / LENGTH(expression)…

Continue ReadingCommonly used Redshift String Functions and Examples
2 Comments

Redshift ANALYZE Command to Collect Statistics and Best Practices

Redshift Analyze command is used to collect the statistics on the tables that query planner uses to create optimal query execution plan using Redshift Explain command. Analyze command obtain sample records from the tables, calculate and store the statistics in STL_ANALYZE table. You can generate statistics on entire tables or on subset of columns. You can specify comma-separated column list for analyze command. How Statistics are collected? Redshift collects statistics in various ways. Statistics are automatically collected for certain database operations. Collect statistics for entire table or subset of columns…

Continue ReadingRedshift ANALYZE Command to Collect Statistics and Best Practices
Comments Off on Redshift ANALYZE Command to Collect Statistics and Best Practices

Amazon Redshift VACUUM Command Syntax, Usage and Examples

Redshift VACUUM command is used to reclaim disk space and resorts the data within specified tables or within all tables in Redshift database. When you delete or update data from the table, Redshift logically deletes those records by marking it for delete. Vacuum command is used to reclaim disk space occupied by rows that were marked for deletion by previous UPDATE and DELETE operations. This command also sorts the data within the tables when specified.  Read: Redshift ANALYZE Command to Collect Statistics and Best Practices Commonly used Redshift Date Functions…

Continue ReadingAmazon Redshift VACUUM Command Syntax, Usage and Examples
Comments Off on Amazon Redshift VACUUM Command Syntax, Usage and Examples

Steps to Connect to Redshift cluster using PostgreSQL – psql

PostgreSQL (psql) is interactive terminal, you can type the queries and get output on terminal. After you create an Amazon Redshift cluster, you can access it using a terminal-based front end from PostgreSQL, psql, to query the data in your Redshift database. Steps to Connect to Redshift cluster using PostgreSQL - psql Below are the steps you can follow to connect to Redshift cluster using PostgreSQL - psql: Install PostgreSQL on Ubuntu – psql If you are using Ubuntu, you can use apt-get to install PostgreSQL. Below is the command:…

Continue ReadingSteps to Connect to Redshift cluster using PostgreSQL – psql
2 Comments

Redshift Unique Key Constraint and Syntax

Redshift Unique key constraint is informational only; they are not enforced by Amazon Redshift. Amazon data warehouse appliance supports referential integrity constraints such as Redshift primary key, foreign key, and unique keys as part of SQL-92 standard requirement. You can create Unique key constraint while creating tables in Redshift database but it will not be enforced while loading Redshift tables. Redshift query planner uses these constraints to create better query execution plan. Read: Redshift Primary Key Constraint and SyntaxAmazon Redshift Foreign Key Constraint and Syntax Redshift Unique Key Constraint Syntax…

Continue ReadingRedshift Unique Key Constraint and Syntax
Comments Off on Redshift Unique Key Constraint and Syntax

Redshift Foreign Key Constraint and Syntax

Redshift foreign key constraint is informational only; they are not enforced by Amazon Redshift. Amazon data warehouse appliance supports referential integrity constraints such as Redshift primary key, foreign key, and unique keys as part of SQL-92 standard requirement. You can create foreign key constraint while creating tables in Redshift database but it will not be enforced while loading Redshift tables. Redshift query planner uses these constraints to create better query execution plan. Read: Amazon Redshift Primary Key Constraint and Syntax Redshift Unique Key Constraint and Syntax Redshift Foreign Key Constraint…

Continue ReadingRedshift Foreign Key Constraint and Syntax
Comments Off on Redshift Foreign Key Constraint and Syntax