Hive Merge Tables Statement – Alternative and Example

The MERGE query or statement in SQL is used to perform incremental load. With the help of SQL MERGE statement, you can perform UPDATE and INSERT simultaneously based on the condition. i.e. you can update old values and insert new records. The MERGE statement in SQL are mainly used to implement slowly changing dimensions. As of now, Hive does not support MERGE statement. In this article, we will check what is Hive Merge tables alternative with an example. Sometimes, update insert is also called UPSERT. Related Article, Slowly changing dimension…

Continue ReadingHive Merge Tables Statement – Alternative and Example
Comments Off on Hive Merge Tables Statement – Alternative and Example

Teradata Joins, Syntax and Examples

Just like Teradata set operators, you can combine records from multiples tables using Teradata joins. Teradata join syntax is similar to other database SQL joins. You can execute SQL queries with different join types on Teradata machine with little or without any change. There are many advantages of using SQL joins, for example, combine columns from multiples tables, update tables using joins. The best way to understand the Teradata joins is to get to know the SQL joins and then consider the join strategies that is used by Teradata database…

Continue ReadingTeradata Joins, Syntax and Examples
Comments Off on Teradata Joins, Syntax and Examples

Teradata NVL and NVL2 Function, Syntax and Examples

The Teradata is one of the widely used MPP relational database systems. Most of the organizations are using Teradata for their high-performance servers such as analytics, back-end systems for reporting servers, etc. Teradata is used with many heterogeneous data sources, you may get lots of junk and null values. You should have a mechanism to deal with such a data. In this article, we will check such a null handling functions. i.e. Teradata NVL function, and NVL2 functions with some examples. Teradata NVL Function  Teradata NVL functions replaces a NULL…

Continue ReadingTeradata NVL and NVL2 Function, Syntax and Examples
Comments Off on Teradata NVL and NVL2 Function, Syntax and Examples

Greenplum Interval Data Type and Conversion Examples

An internal data types in Greenplum are associated with time span. The interval data type allows you to store and manipulate a period of time in years, months, days, hours, minutes, seconds, etc. The interval values are very useful when doing date or time arithmetic. The size of Interval data type in Greenplum are 12 bytes that can store a period with the allowed range is from -178,000,000 years to 178,000,000 years. In this article, we will check Greenplum Interval Data Type. Greenplum Interval Data Type Syntax Below is the syntax of interval data types in…

Continue ReadingGreenplum Interval Data Type and Conversion Examples
Comments Off on Greenplum Interval Data Type and Conversion Examples

Greenplum Different Joins and Examples

Joins in SQL are used to retrieve or combine specific columns from two or more tables based on common data columns available in the tables. Columns from multiple tables are integrated using different joins. In this article, we will check Greenplum different joins and demonstrate using live examples. These joins are same as PostgreSQL joins. Test Data Below are the tables and associated data that we will be using to demonstrate different joins available in Greenplum database. Table1: template1=# select * from table1; id | name | city ----+-------+----------- 1…

Continue ReadingGreenplum Different Joins and Examples
Comments Off on Greenplum Different Joins and Examples

Greenplum WITH Clause Syntax, Usage and Examples

The WITH clause in SQL is sometimes referred to as a common table expression (CTE), is an optional clause that will always precedes SELECT statement of the query block. WITH clause in Greenplum contains a sub-query that is defined as a temporary table like view. Each sub-query in the WITH clause is associated with a table name, an optional list of column names that CTE returns, and a query expression that evaluates to a table (usually a SELECT statement). In this article, we will check how to use Greenplum WITH…

Continue ReadingGreenplum WITH Clause Syntax, Usage and Examples
Comments Off on Greenplum WITH Clause Syntax, Usage and Examples

Execute SQL Script File using Greenplum psql Variable Substitution

Variable substitution is one of the important options that is widely used when you are executing any SQL scripts from the command line or from any shell scripts. Like any other databases such as Netezza, Redshift and Vertica, Greenplum also supports variable substitution using PostgreSQL or psql -v option. In this article, we will check how to execute a SQL script file using Greenplum psql variable substitution. We will also see some working example that uses Greenplum psql variable substitution method. Execute SQL Script File using Greenplum psql Variable Substitution…

Continue ReadingExecute SQL Script File using Greenplum psql Variable Substitution
Comments Off on Execute SQL Script File using Greenplum psql Variable Substitution

Hive Drop Column Alternative and Examples

Apache Hive is a data warehouse framework on top of Hadoop ecosystem. Hive works well for all your batch processing. It is not true data warehouse platform as it does not provide support for real-time analytics. There are many features missing in Hive that are available in traditional relational databases. One of such features is DROP COLUMNS using ALTER TABLE statements. In this article, we will check Hive drop column alternative with some examples. Hive Drop Column Alternative There are two approaches that you can follow if you want to…

Continue ReadingHive Drop Column Alternative and Examples
Comments Off on Hive Drop Column Alternative and Examples

Greenplum SET ON_ERROR_STOP using psql and Examples

On Greenplum MPP data warehouse appliance, you will be executing multiple SQL statement in the single SQL file. This is required when you are refreshing fact or dimension table by creating intermediate stage tables. In such a refresh SQL file, there will be multiple create, delete, and drop statements. You have to take care of any errors that might occur in any of the SQL statements in file. In this article, we will discuss about the Greenplum SET ON_ERROR_STOP variable to stop the execution in case one of the SQL…

Continue ReadingGreenplum SET ON_ERROR_STOP using psql and Examples
Comments Off on Greenplum SET ON_ERROR_STOP using psql and Examples

How to Export Greenplum Query Results into CSV?

In a data warehouse environment, most of the tables are secured. The database administrator will allow only authorized used to access records from the tables. The decision makers analyze the flat files created from the database tables to come up with business-critical decision. Saving results of a query or a database table in any relational database is one of the basic and important work. The created flat files or CSV files then be transported using any mode of electronic transport such as email, FTP, SFTP, etc. in this article, we…

Continue ReadingHow to Export Greenplum Query Results into CSV?
Comments Off on How to Export Greenplum Query Results into CSV?