Skip to main content

Oracle LIKE & Wildcards 🔍

Mentor's Note: What if you only remember that a student's name starts with "Vi"? You can't use =, but you can use LIKE. It's the search engine of the database world. 💡


🌟 The Scenario: The Smudged Record 📄

Imagine an old file where the end of the name is unreadable. You only see "Sma...".

  • Action: You search for LIKE 'Sma%'.
  • Result: You find "Smart", "Small", and "Smathers".

💻 1. The Wildcard Tools

WildcardMeaningAnalogy
%Zero or more charactersThe "Infinite Bridge" 🌉
_Exactly one characterThe "Single Footstep" 👣

Examples

-- Starts with 'A'
SELECT name FROM students WHERE name LIKE 'A%';

-- Has 'sh' anywhere
SELECT name FROM students WHERE name LIKE '%sh%';

-- 4 letter name starting with 'R'
SELECT name FROM students WHERE name LIKE 'R___';

🏗️ Architect's Note: The Index Trap 🛡️

In Oracle, if you start your pattern with a wildcard (e.g., LIKE '%son'), the database cannot use an index. It must read the whole table.

  • Architect's Advice: Always try to put text before the wildcard if performance matters! LIKE 'Son%' is much faster than LIKE '%Son%'.

📈 Learning Path

📍 Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
📍 Address
2/66 Faram Street, Rustompura
Surat395002, Gujarat, India
📞 Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition — Areas We Serve in Surat

AdajanAlthanAmroliAthwaAthwalinesBhagalBhatarBhestanCanal RoadChowkCitylightDumasGaurav PathGhod Dod RoadHaziraJahangirpuraKamrejKapodraKatargamLimbayatMagdallaMajura GateMota VarachhaNanpuraNew CitylightOlpadPalPandesaraParle PointPiplodPunaRanderRing RoadRustampuraSachinSalabatpuraSarthanaSosyo CircleUdhnaVarachhaVed RoadVesuVIP Road
📞 Call Sir💬 WhatsApp Sir