Why Teradata’s LIKE operator behaves differently for CHAR and VARCHAR columns

Have you observed the different behavior of the Teradata LIKE operator when applied to a CHAR or VARCHAR data type column? Consider the following table as an illustration:

Creating a table:

CREATE TABLE TheLikeTest (
    TheVarchar VARCHAR(20),
    TheChar CHAR(20)
);

To illustrate, we will add a single row.

INSERT INTO TheLikeTest VALUES ('Anytext','Anytext');

We will run the SQL statement for the column with the VARCHAR data type.


SELECT TheVarchar FROM TheLikeTest WHERE TheVarchar LIKE '%t';
-> Result: 'Anytext' (1 Row)

Next, we will execute the same query on the column with a CHAR data type.


SELECT TheChar FROM TheLikeTest WHERE TheChar LIKE '%t';
-> Result: No rows

The second query yielded no results due to a 20-space addition to the CHAR data type column. The column content contains a space character instead of the expected ‘t’ at the end.

Share your solution in the comments to prevent this undesirable behavior.

Related Services

⚡ Need Help Optimizing Your Data Platform?

We cut data platform costs by 30–60% without hardware changes. 25+ years of hands-on tuning experience.

Explore Our Services →

📋 Considering a Move From Teradata?

Get a personalized migration roadmap in 2 minutes. We have migrated billions of rows from Teradata to Snowflake, Databricks, and more.

Free Migration Assessment →

📊 Data Platform Migration Survey

Help us map where the industry is heading. Results are public — see what others chose.

1. What is your current data platform?

2. Where are you migrating to (or evaluating)?

Migrating FROM
Migrating TO

Thanks for voting! Share this with your network.

Follow me on LinkedIn for daily insights on data warehousing and platform migrations.

Stay Ahead in Data Warehousing

Get expert insights on Teradata, Snowflake, BigQuery, Databricks, Microsoft Fabric, and modern data architecture — delivered to your inbox.

4 thoughts on “Why Teradata’s LIKE operator behaves differently for CHAR and VARCHAR columns”

Leave a Comment

DWHPro

Expert network for enterprise data platforms. Senior consultants, project teams built for your challenge — across Teradata, Snowflake, Databricks, and more.

📍Vienna, Austria & Jacksonville, Florida

Quick Links
Services Team Teradata Book Blog Contact Us
Connect
LinkedIn → [email protected]
Newsletter

Join 4,000+ data professionals.
Weekly insights on Teradata, Snowflake & data architecture.