DataSunrise is sponsoring RSA Conference2024 in San Francisco, please visit us in DataSunrise's booth #6178

Redshift Data Types

Redshift Data Types

Redshift Data Types

In the world of data warehousing and analytics, Amazon Redshift has emerged as a powerful and scalable solution. As a column-oriented database, Redshift offers a range of data types to efficiently store and process large volumes of structured data. Understanding Redshift data types is crucial for optimizing query performance and ensuring data integrity. In this article, we will explore the basics of Redshift data types, compare them with SQL samples, and discuss the concept of masking these data types.

What is Redshift?

Amazon Redshift is a fully managed, petabyte-scale data warehousing service provided by Amazon Web Services (AWS). It enables businesses to store and analyze massive amounts of data using SQL-based tools and standard BI applications. Cluster architecture, consisting of nodes, to distribute data and processing across multiple machines, enables high performance and scalability.

Redshift Data Types

Redshift supports a variety of data types to accommodate different types of data. You can categorize these types into several groups.

1. Numeric Types:

  • SMALLINT: 2-byte signed integer
  • INTEGER: 4-byte signed integer
  • BIGINT: 8-byte signed integer
  • DECIMAL: Fixed-point number with user-specified precision
  • REAL: Single-precision floating-point number
  • DOUBLE PRECISION: Double-precision floating-point number

2. Character Types:

  • CHAR: Fixed-length character string
  • VARCHAR: Variable-length character string
  • NVARCHAR: Variable-length Unicode character string

3. Datetime Types:

  • DATE: Calendar date (year, month, day)
  • TIMESTAMP: Date and time (without time zone)
  • TIMESTAMPTZ: Date and time (with time zone)

4. Boolean Type:

  • BOOL: Logical Boolean (true/false)

5. Other Types:

  • GEOMETRY: Spatial data type for representing geometric objects
  • HLLSKETCH: HyperLogLog sketch for approximate distinct counting
  • SUPER: Semi-structured data type for storing JSON-like data

Redshift Data Types vs. SQL Samples

Let’s compare some Redshift data types with their SQL counterparts using code samples.

Example 1: Creating a table with various data types

CREATE TABLE employees (
name VARCHAR(100),
salary DECIMAL(10, 2),
hire_date DATE

In this example, we create a table named “employees” with columns of different data types. The “id” column is of type INTEGER, “name” is VARCHAR(100), “age” is SMALLINT, “salary” is DECIMAL(10, 2), and “hire_date” is DATE.

Example 2: Inserting data into the table

(1, 'John Doe', 35, 5000.00, '2022-01-01'),
(2, 'Jane Smith', 28, 4500.50, '2023-03-15');

Here, we insert two rows of data into the “employees” table. The values correspond to the defined data types for each column.

Masking Redshift Data Types

Data masking is a technique used to protect sensitive information by replacing it with fictitious but realistic data. Redshift supports various masking functions to obfuscate data based on specific rules or patterns.

Example 3: Masking sensitive data using Redshift’s masking functions

firstname_mask(name) AS masked_name,
mask_number(salary, 'N', 2) AS masked_salary,
mask_date(hire_date, 'D') AS masked_hire_date
FROM employees;

In this example, we retrieve data from the “employees” table while applying masking functions to sensitive columns. The firstname_mask function masks the first name in the “name” column. Mask_number function masks the “salary” column by replacing the last 2 digits with ‘N’. The mask_date function masks the “hire_date” column by replacing the day component with ‘D’.

The output would look something like this:

id | name      | age | masked_name | masked_salary | masked_hire_date
1  | John Doe  | 35  | J*** D**    | 5000.NN       | 2022-01-DD
2  | Jane Smith| 28  | J*** S****  | 4500.NN       | 2023-03-DD

As you can see, the sensitive information in the “name”, “salary”, and “hire_date” columns is masked while preserving the format and data type.


Understanding Redshift data types is essential for effective data management and query optimization in Amazon Redshift. By leveraging the appropriate data types and masking techniques, you can ensure data integrity, protect sensitive information, and optimize query performance. Redshift’s support for a wide range of data types and masking functions makes it a versatile and secure data warehousing solution.

DataSunrise offers exceptional and flexible tools for security, audit rules, masking, and compliance in Redshift and other databases. Our solutions provide comprehensive data protection and help organizations meet regulatory requirements. We invite you to visit the DataSunrise team for an online demo to explore how our tools can enhance your data security and compliance efforts.


Accessing Cloud Data

Accessing Cloud Data

Learn More

Need Our Support Team Help?

Our experts will be glad to answer your questions.

General information:
[email protected]
Customer Service and Technical Support:
Partnership and Alliance Inquiries:
[email protected]