--1 -> Search users who play either football OR baseball AND cricket
--2 -> Search users who have interest in music
--3 -> Print the location information and their hobbies, for all the users
-- Declare a cursor that fetches users with hobbies related either to football or baseball and cricket.
-- Here (basefoot)([[:space:]]){0,}ball([^.]*)cricket expression returns true if the 'hobbies' column contains
-- values like football,baseball, base ball, foot ball etc. ([^.]*) means occurence of any character multiple
-- times. The 'i' indicates case-insensitive search
SELECT username,hobbies
FROM userinfo
WHERE REGEXP_LIKE(hobbies,'(basefoot)([[:space:]]){0,}ball([^.]*)cricket','i');
-- Declare a cursor to fetch the user data if their hobbies are related to music.
-- The 'musicviolinguitarsing(ering)' pattern returns true if the given
-- data matches any of music,violin, guitar, singer, singing character patterns.
-- sing(ering) represents either singer or singing character pattern.
SELECT username,hobbies
FROM userinfo
WHERE REGEXP_LIKE(hobbies,'musicviolinguitarsing(ering)','i');
-- This retrieves the location of all the users in the database.
-- REGEXP_SUBSTR(WEBSITE, ',[^,]+',1,2) fetches the second substring bounded by commas
SELECT username, hobbies, REGEXP_SUBSTR(address, ',[^,]+',1,2)
FROM userinfo ;
Halim, a Georgia Tech graduate Senior Database Engineer/Data Architect based in Atlanta, USA, is an Oracle OCP DBA and Developer, Certified Cloud Architect Professional, and OCI Autonomous Database Specialist. With extensive expertise in database design, configuration, tuning, capacity planning, RAC, DG, scripting, Python, APEX, and PL/SQL, he combines technical mastery with a passion for innovation. Notably, Halim secured 16th place worldwide in PL/SQL Challenge Cup Playoff on the year 2010.
Monday, September 28, 2009
Subscribe to:
Post Comments (Atom)
My Blog List
-
-
-
ASSM states3 weeks ago
-
UKOUG Discover 20241 month ago
-
-
-
-
-
-
-
-
Moving Sideways8 years ago
-
-
Upcoming Events...11 years ago
-
No comments:
Post a Comment