Академический Документы
Профессиональный Документы
Культура Документы
Types:
• CLOB: Character
• NCLOB: Multibyte character
• BLOB: Binary
• BFILE: Binary file
Initializing a CLOB:
INSERT INTO employee(emp_id,emp_details)
VALUES(101,EMPTY_CLOB());
PL/SQL:
• Stands for Procedural Language extension to SQL
• Is Oracle Corporation’s standard data access
language for relational databases
• Seamlessly integrates procedural constructs with
SQL
PL/SQL:
• Provides a block structure for executable units of
code. Maintenance of code is made easier with
such a well-defined structure.
• Provides procedural constructs such as:
– Variables, constants, and types
– Control structures such as conditional statements
and loops
– Reusable program units that are written once and
executed many times
PL/SQL engine
procedural Procedural
PL/SQL statement
block executor
SQL
SQL statement
executor
SQL 1
SQL 2
…
SQL
IF...THEN
SQL
ELSE
SQL
END IF;
SQL
D-10 Copyright © 2004, Oracle. All rights reserved.
Benefits of PL/SQL
DECLARE (Optional)
Variables, cursors, user-defined exceptions
BEGIN (Mandatory)
- SQL statements
- PL/SQL statements
EXCEPTION (Optional)
Actions to perform
when errors occur
END; (Mandatory)
Anonymous Procedure
Function
[DECLARE] PROCEDURE name FUNCTION name
IS RETURN datatype
IS
BEGIN BEGIN BEGIN
--statements --statements --statements
RETURN value;
[EXCEPTION] [EXCEPTION] [EXCEPTION]
Database Server
Tools Constructs Constructs
Anonymous blocks Anonymous blocks
Application procedures Stored procedures or
or functions functions
Application packages Stored packages
SET SERVEROUTPUT ON
…
DBMS_OUTPUT.PUT_LINE(' The First Name of the
Employee is ' || f_name);
…
ABC
A method of
describing both Several new
simple and complex functions to
patterns for support regular
searching and expressions
manipulating
SELECT street_address,
REGEXP_INSTR(street_address,'[^[:alpha:]]')
FROM locations
WHERE
REGEXP_INSTR(street_address,'[^[:alpha:]]')> 1;
• Simplifying design
• Modeling data
• Optimizing table and index design
• Using views
• Writing efficient SQL
• Sharing cursors
• Using bind variables
• Using dynamic SQL
• Simple tables
• Well-written SQL
• Indexing only as required
• Retrieving optimum information
• Index keys
– Primary key
– Unique key
– Foreign keys
• Index often-queried data
• Use SQL as a guide to index design.
• Reduces parsing
• Dynamically adjusts memory
• Improves memory usage