Академический Документы
Профессиональный Документы
Культура Документы
איציק הדר
יונתן טולדנו
Certified Oracle 10g Technician
Agenda
• Regular Expressions
• Native Floating-Point Data Type
• LOB Enhancements
• PL/SQL Performance Improvement
• Data Pump
Regular Expressions
SELECT *
FROM park
WHERE description LIKE '%acre%';
inStr ADDRESS
----- -------------------------------------
27 Mr. Smith, Good St., CA – 98765-9876
11 Jo, NY-NY 14357-6543
23 Helen, sun street, FL 87876
…
REGEXP_INSTR - Explain
SELECT REGEXP_INSTR(address,
'[[:digit:]]{5}(-[[:digit:]]{4})?$')
Match 0
Literal
Or 1 time
POSIX: Numeric
digits only
Character List
RS
-------------
, second ,
REGEXP_SUBSTR - Explain
SELECT REGEXP_SUBSTR
(‘first, second , third’, ‘, [^,]*,’) rs
FROM dual;
Search for a
comma followed
by a space
RR
------------------------
Ellen, Hildi : Smith
REGEXP_REPLACE- Explain
SELECT REGEXP_REPLACE(
‘Smith Hildi Ellen’,
(.*) (.*) (.*),
‘\3, \2 : \1’) rr
FROM dual;
( ) - Subexpression
(.) - Match any character within the subexpression
(.*) - Match any character in the subexpression zero or more times
(.*) (.*) - Whitspace between subexpressions mast be matched as well
\digit - Capture the corresponding subexpression and reference the
subexpression value. This is called “Backreferences” and is
used in the example to return the subexpressions in a new
format (including whitespace, comma & colon)
Practical Uses: Constraints
ALTER TABLE students ADD CONSTRAINT std_snn_chk
(REGEXP_LIKE (snn,
‘^([[:digit]]{3}-[[:digit]]{2}-[[:digit]]{4}|[[:digit]]{9})$’));
Legal values:
123-45-6789
OR
123456789
Practical Uses: Indexes
• Use function-based indexes:
CREATE INDEX acre_ind
ON park (REGEXP_SUBSTR(
REGEXP_SUBSTR(description,
'[0-9]+(-| )acre'),'[0-9]+'));
• To support regular expression queries:
SELECT * FROM park
WHERE
REGEXP_SUBSTR(REGEXP_SUBSTR(description,
'[0-9]+(-| )acre'),'[0-9]+') = 217;
Practical Uses: Views
• Hide the complexity from users:
CREATE VIEW park_acreage as
SELECT park_name,
REGEXP_SUBSTR(
REGEXP_SUBSTR(
description,
'[0-9]+(-| )acre'),
'[0-9]+') acreage
FROM park;
Practical Uses: PL/Sql
• REGEXP_LIKE acts as a Boolean function in
PL/SQL:
IF REGEXP_LIKE(description,'[0-9]+(-| )acre') THEN
acres := REGEXP_SUBSTR(
REGEXP_SUBSTR(description,
'[0-9]+(-| )acre'),'[0-9]+');
...
SELECT *
FROM park
WHERE REGEXP_LIKE(
description,
'[0-9]+.acre',
'in');
String anchors
INSERT INTO employee (surname)
VALUES ('Ellison' || CHR(10) ||
'Gennick');
SELECT * FROM
EMPLOYEE
WHERE REGEXP_LIKE(
Yes!
surname,'^Ellison');
String anchors
INSERT INTO employee (surname)
VALUES ('Ellison' || CHR(10) ||
'Gennick')
SELECT * FROM
EMPLOYEE
WHERE REGEXP_LIKE(
No!
surname,'^Gennick');
String anchors
INSERT INTO employee (surname)
VALUES ('Ellison' || CHR(10) ||
'Gennick')
SELECT * FROM
EMPLOYEE
WHERE REGEXP_LIKE(
Yes!
surname,'^Gennick','m');
Locale Support
• Full Locale Support
– All character sets
– All languages
• Case and accent insensitive searching
• Linguistic range
• Character classes
• Equivalence classes
Character Sets and
Languages
• For example, you can search for Hebrew
names beginning with עand ending with ל:
SELECT *
FROM employee
WHERE REGEXP_LIKE(
surname,
'^[[ע:alpha:]]*ל$');
Case- and Accent-
Insensitive Searching
• Respect for NLS settings:
ALTER SESSION
SET NLS_SORT = GENERIC_BASELETTER;
• With this sort, case won't matter and an
expression such as:
REGEXP_INSTR(x,'resume')
will find "resume", "résumé", "Résume", etc.
Linguistic Range
• Ranges respect NLS_SORT settings:
NLS_SORT=GERMAN a,b,c…z
[a-z]
NLS_SORT=GERMAN_CI a,A,b,B,c,C…z,Z
Character Classes
• Character classes such as [:alpha:] and
[:digit:] encompass more than just Latin
characters.
• For example, [:digit:] matches:
– Latin 0 through 9
– Arabic-Indic ٠ through ٩
– And more
Equivalence Classes
• Ignore case and accents without changing
NLS_SORT:
REGEXP_INSTR(x,'r[[=e=]]sum[[=e=]]')
• Finds 'resume', 'résumé', and 'rEsumE'
Regular Expression
Conclusion
• 80% of application logic is string processing then
it's hard to think of an application that could not
make use of regular expressions.
• Oracle Regular Expressions provide versatile string
manipulation in the database instead of
externalized in middle tier logic
• They are Locale sensitive and support character
large objects
• Available in both SQL and PL/SQL
Agenda
• Regular Expressions
• Native Floating-Point Data Type
• LOB Enhancements
• Collection Enhancement
• PL/SQL Performance Improvement
• Data Pump
Native Floating-Point Data Type
• Compiler warnings
Front-end
IR == Diana
Back-end
PVM
PL/SQL Native Compilation
• Starting in Oracle9i Release 1, PL/SQL
program units can be compiled directly into
machine code.
– Stored procedures, functions, packages, types,
and triggers
• Alternatively, PL/SQL code can be
interpreted as in Oracle8i and earlier.
Front-end
IR == Diana
Back-end
Object codeObject
== MCode
codeor==Native
MCode machine code
PVM Hardware
Testing by Oracle Team
• The next slide shows much more detail
Program Elapsed
exp out of the box: direct=y 0 hr 10 min 40 sec
exp tuned: direct=y buffer=2M recordlength=64K 0 hr 04 min 08 sec
expdp out of the box: Parallel=1 0 hr 03 min 12 sec
imp out of the box 2 hr 26 min 10 sec
imp tuned: buffer=2M recordlength=64K 2 hr 18 min 37 sec
impdp out of the box: Parallel=1 0 hr 03 min 05 sec
Keep in Mind:
Thank You
hadar@hi-tech.co.il
toledano@hi-tech.co.il