Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:26:34+00:00 2026-06-12T01:26:34+00:00

Seems like DB2 and Oracle implement character comparison by padding the shorter string with

  • 0

Seems like DB2 and Oracle implement character comparison by padding the shorter string with spaces on right. But why?

Would it not be better if the database engine had trimmed the larger character value instead of padding the shorter one with spaces? i.e.
if my query is SELECT * from SOME_TABLE where CUSTOMER_NAME = 'Popeye ', the database engine ends up adding spaces to every row in SOME_TABLE, when instead it could have trimmed the value passed here i.e. 'Popeye '

Also, just curious to understand why does Oracle and DB2 only add spaces on right ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:26:35+00:00Added an answer on June 12, 2026 at 1:26 am

    You are confusing the different types of characters and what is happening. When you execute:

    SELECT * from SOME_TABLE where CUSTOMER_NAME = 'Popeye '
    

    No spaces are added “to every row in SOME_TABLE”. The only question is the width of the results. This width is set by the properties of the columns in SOME_TABLE, not by what appears in the WHERE clause.

    If your CUSTOMER_NAME is declared as a char(x) value, then the string must have that length. Say, it is char(10) and you assign ‘Popeye’ to it. The value has six characters and this must be padded to 10, somehow. The SQL standard is to pad on the right hand side, making the value 'Popeye '.

    If you want variable length strings, then use varchar or varchar2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like everyone always ignores the time part, but how would you compare two
Seems like there should be... Right now it just seems like magic that you
Seems like this should be obvious, but how do I send arrow key presses
Seems like this should be simple, but powershell is winning another battle with me.
Seems like it would be better if you did commit followed by merge. I'm
I have created a Database in DB2 and tables with relationships. I would like
Seems like this should be simple enough but for whatever reason I am unable
Seems like a basic question but I just can't figure it out: xcode 5.0
Seems like the problem with this is the PHP syntax, but no luck in
Can SQL Server or db2 do entire database exports like oracle (using exp command)?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.