Psql Invalid Value for Parameter client_encoding – Redshift

In my other article, we have seen steps to connect to Redshift cluster using PostgreSQL PSQL. When you connect to Amazon Redshift from Windows command prompt, you may experience the client encoding issue. In this article, we will check how to resolve "psql: FATAL: invalid value for parameter "client_encoding": "WIN1252"" issue. This is issue is mostly seen when connecting using Windows command prompt. Postgres PSQL Introduction PSQL is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results. Since Redshift…

Continue ReadingPsql Invalid Value for Parameter client_encoding – Redshift
Comments Off on Psql Invalid Value for Parameter client_encoding – Redshift

Redshift ROWNUM Pseudo Column Alternative

There is no ROWNUM pseudo column in Redshift. If you are coming from Oracle database background, you will find it difficult in Redshift without ROWNUM pseudo column. The one possible solution to this is ROW_NUMBER() analytical function as Redshift ROWNUM pseudo column alternative. ROWNUM is sometime useful when you are working with multi-level SQL queries. You can restrict the rows using ROW_NUMBER functions. Read: Redshift String Functions and Examples Amazon Redshift Date Functions and Examples Redshift Analytics Functions and Examples Redshift also support a LIMIT clause to restrict the output.…

Continue ReadingRedshift ROWNUM Pseudo Column Alternative
1 Comment

Amazon Redshift Date Format Conversion and Examples

Date data type is one of the complicated type is database. Date data types are used to store the date and time fraction values. Amazon Redshift Date format includes four data types, and are used to store the date with time details: DATE: for year, month, day storage. TIME: for hour, minute, second, fraction with (includes 6 decimal positions). TIMESTAMPTZ: same as TIME, also includes time zone information. TIMESTAMP: for year, month, day, hour, minute, second, fraction (includes 6 decimal positions). Amazon Redshift Date Format Conversion Redshift can convert quoted…

Continue ReadingAmazon Redshift Date Format Conversion and Examples
Comments Off on Amazon Redshift Date Format Conversion and Examples

Redshift SET ON_ERROR_STOP using psql and Examples

On Redshift data warehouse appliance, you will be executing multiple SQL statement in single SQL file. In this article, we will discuss about the Redshift SET ON_ERROR_STOP variable to stop the execution in case one of the sql statement encountered error inside SQL script file. Without setting this system variable, Amazon Redshitf will continue with other statements ignoring the failed query. PostgreSQL (psql) EXIT Status psql returns following EXIT status when you are executing Redshfit SQL from files: 0: to the shell if it finished sql execution normally. 1: if…

Continue ReadingRedshift SET ON_ERROR_STOP using psql and Examples
Comments Off on Redshift SET ON_ERROR_STOP using psql and Examples

Run Redshift SQL Script File using psql Variable Substitution

PostgreSQL or psql allows the variable substitution using -v option in Redshift sql query files. The variable substitution is very important when you are calling the Redshift sql scripts from shell or any other scripting language. You can pass the values to query that you are calling using -v option. In this article, we will see how to run Redshift sql script file using psql variable substitution. We also see some of the working examples that uses the psql variable substitution method. Run Redshift SQL Script File using psql Variable…

Continue ReadingRun Redshift SQL Script File using psql Variable Substitution
2 Comments

Access Redshift using psql without Password Prompt – Use psql System Variables

Users can access Amazon Redshift database using a PostgreSQL- compatible psql client. Users can always connect to the Redshift database via leader node. In this article, we will see how to access redshift using psql without password prompt. You can use psql system variables to store required credentials. Access Redshift using psql without Password Prompt Password less access is useful when you are trying to execute Redshift queries from scripts such as shell or perl scripts. Option 1. Export Amazon Redshift Database Environmental Variables In order to access Redshift database…

Continue ReadingAccess Redshift using psql without Password Prompt – Use psql System Variables
Comments Off on Access Redshift using psql without Password Prompt – Use psql System Variables