DB2 question with LIKE concept

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

DB2 question with LIKE concept

Post by Gurugars » Wed Apr 22, 2015 6:35 pm

Dear friends,

I was wondering how LIKE clause will behave in the following scenario.

I have a query where I'm using LIKE clause as follows,

Code: Select all

SELECT COL-1, COL-2, COL-3
   FROM TABLE1
WHERE COL-1 LIKE 'ABC%'
Here assume that the COL-1 is of size 4 CHAR. In the above case I believe the entire table will be scanned as I've used LIKE clause (assume COL-1 is not indexed).

Now, If I'm checking exactly the same length data against the LIKE clause, will it behave like EQUAL condition check.

Code: Select all

SELECT COL-1, COL-2, COL-3
   FROM TABLE1
WHERE COL-1 LIKE 'ABCD'
Here there is no patern checking, so will it behave like COL-1 = 'ABCD'.?

I've tried this myself as I don;t have much data in our tables, I couldn't see the difference.

Please let me know if the above scenario is not clear.


Thanks in advance.
Guru:-)

You're never fully dressed without a smile :)

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Mon Apr 27, 2015 6:00 pm

have you looked at the EXPLAIN output for these queries?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

academyindia4

Topic deleted by Admin

Post by academyindia4 » Fri Jan 15, 2016 8:49 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others