Tải bản đầy đủ (.pdf) (117 trang)

Chapter 40:The Hitchhiker’s Guide to Database Administration821is actively used by the pot

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.34 MB, 117 trang )

Chapter 40: The Hitchhiker’s Guide to Database Administration
821
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 40
Blind Folio 40:821
is actively used by the database is backed up. These files provide a complete image of the
database as it existed at the moment it was shut down.
NOTE
You should not rely on an offline backup performed following a
shutdown abort, since it may be inconsistent. If you must perform
a shutdown abort, you should restart the database and perform a
normal shutdown or a shutdown immediate or a shutdown
transactional prior to beginning your offline backup.
The following files should be backed up during cold backups:

All datafiles

All control files

All online redo logs
You may optionally choose to back up the database initialization parameter file, particularly
if the backup will serve as the basis for a disaster recovery process.
Having all of these files backed up
while the database is closed
provides a complete image
of the database as it existed at the time it was closed. The full set of these files could be retrieved
from the backups at a later date and the database would be able to function. It is
not
valid to
perform a file system backup of the database while it is open unless an online backup is being


performed (as discussed later in this chapter).
Ideally, all of the datafiles are located in directories at the same level on each device. For
example, all database files may be stored in an instance-specific subdirectory under an /oracle
directory for each device (such as /db01/oracle/MYDB). Directories such as these should contain
all of the datafiles, redo log files, and control files for a database. The only file you may optionally
add to the offline backup that will not be in this location is the production initialization parameter
file, which should be in either the /app/oracle/admin/
INSTANCE_NAME
/pfile subdirectory under the
Oracle software base directory or the /database directory under the Oracle software home directory.
If you use the directory structure in the prior example, your backup commands are greatly
simplified, since you will be able to use wildcards in the filenames. After shutting down the
database, back up the files to the backup destination area (either a tape or a separate disk area).
NOTE
If necessary, you can also back up the init.ora and config.ora files at
the same time.
Since offline backups involve changes to the database’s availability, they are usually
scheduled to occur at night.
Offline backups are very reliable. To reduce their impact on the database’s availability,
you may use online backups. As described in the following section, online backups use Oracle’s
ARCHIVELOG mode to allow consistent file system backups during database usage.
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:39 PM
Color profile: Generic CMYK printer profile
Composite Default screen
822
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 40

Blind Folio 40:822
Online Backups
You can use online backups for any database that is running in ARCHIVELOG mode. In this mode,
the online redo logs are archived, creating a full log of all transactions within the database.
Oracle writes to the online redo log files in a cyclical fashion; after filling the first log file, it
begins writing to the second log until that one fills, and then begins writing to the third. Once the
last online redo log file is filled, the LGWR (Log Writer) background process begins to overwrite
the contents of the first redo log file.
When Oracle is run in ARCHIVELOG mode, the ARC0-ARC9 (Archiver) background processes
make a copy of each redo log file before overwriting it. These archived redo log files are usually
written to a disk device. The archived redo log files may also be written directly to a tape device,
but this tends to be very operator-intensive.
You can perform file system backups of a database while that database is open, provided the
database is running in ARCHIVELOG mode. An online backup involves setting each tablespace
into a backup state, backing up its datafiles, and then restoring the tablespace to its normal state.
NOTE
When using the Oracle-supplied RMAN utility, you do not have to
place each tablespace into a backup state. The utility will put the
tablespace into and take it out of the backup state automatically.
The database can be fully recovered from an online backup, and can, via the archived
redo logs, be rolled forward to any point in time. When the database is then opened, any
committed transactions that were in the database at that time will have been restored and
any uncommitted transactions will have been rolled back.
While the database is open, the following files are backed up:

All datafiles

All archived redo log files

One control file, via the alter database command

Online backup procedures are very powerful for two reasons. First, they provide full
point-in-time recovery. Databases that are not running in ARCHIVELOG mode can only be
recovered to the point in time when the backup occurred. Second, they allow the database
to remain open during the file system backup. Thus, even databases that cannot be shut
down due to user requirements can still have file system backups.
Getting Started
To make use of the ARCHIVELOG capability, the database must first be placed in ARCHIVELOG
mode. The following listing shows the steps needed to place a database in ARCHIVELOG
mode. Run SQLPLUS and mount the database (providing its name in place of “mydb” in these
examples), then alter it as shown here:
SQL> connect system/manager as sysdba
SQL> startup mount mydb;
SQL> alter database archivelog;
SQL> alter database open;
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:39 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Chapter 40: The Hitchhiker’s Guide to Database Administration
823
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 40
Blind Folio 40:823
The following command will display the current ARCHIVELOG status of the database from
within SQLPLUS:
archive log list
NOTE
To see the currently active online redo log and its sequence number,
query the V$LOG dynamic view.

To change a database back to NOARCHIVELOG mode, use the following set of commands
after shutting down the database:
SQL> connect system/manager as sysdba
SQL> startup mount mydb;
SQL> alter database noarchivelog;
SQL> alter database open;
A database that has been placed in ARCHIVELOG mode will remain in that mode until it is
placed in NOARCHIVELOG mode. The location of the archived redo log files is determined by
the settings in the database’s parameter file. The parameters to note in Oracle9i are as follows
(with sample values):
log_archive_dest_1 = /db01/oracle/arch/CC1/arch
log_archive_dest_state_1 = ENABLE
log_archive_start = TRUE
log_archive_format = arch%s.arc
In this example, the archived redo log files are being written to the directory
/db01/oracle/arch/CC1. The archived redo log files will all begin with the letters “arch,”
followed by a sequence number. For example, the archived redo log file directory may
contain the following files:
arch_170.arc
arch_171.arc
arch_172.arc
Each of these files contains the data from a single online redo log. They are numbered
sequentially, in the order in which they were created. The size of the archived redo log files
varies, but does not exceed the size of the online redo log files.
If the destination directory of the archived redo log files runs out of space, then ARCH will
stop processing the online redo log data and the database will temporarily hang. This situation
can be resolved by adding more space to the archived redo log file destination disk or by backing
up the archived redo log files and then removing them from this directory.
NOTE
Never delete archived redo log files until you have backed them up

and verified that you can restore them successfully.
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:39 PM
Color profile: Generic CMYK printer profile
Composite Default screen
824
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 40
Blind Folio 40:824
Although the initialization parameter LOG_ARCHIVE_START parameter may be set to TRUE,
the database will
not
be in ARCHIVELOG mode unless you have executed the alter database
archivelog command shown earlier in this section. Once the database is in ARCHIVELOG mode,
it will remain in that mode through subsequent database shutdowns and startups until you
explicitly place it in NOARCHIVELOG mode via the alter database noarchivelog command.
Performing Online Database Backups
Once a database is running in ARCHIVELOG mode, you can back it up while it is open and
available to users. This capability allows round-the-clock database availability to be achieved
while still guaranteeing the recoverability of the database.
Although online backups can be performed during normal working hours, they should be
scheduled for the times of the least user activity for several reasons. First, the online backups will
use operating system commands to back up the physical files, and these commands will use the
available I/O resources in the system (impacting the system performance for interactive users).
Second, while the tablespaces are being backed up, the manner in which transactions are written
to the archived redo log files changes. When you put a tablespace in “backup” mode, the DBWR
process writes all of the blocks in the buffer cache that belong to any file that is part of the tablespace
back to disk. When the blocks are read back into memory and then changed, they will be copied

to the log buffer the first time that a change is made to them. As long as they stay in the buffer
cache, they will not be recopied to the online redo log file. This will use a great deal more space
in the archived redo log file destination directory.
The command file for a hot backup has three parts:
1. A tablespace-by-tablespace backup of the datafiles, which in turn consists of
a. Setting the tablespace into backup state
b. Backing up the tablespace’s datafiles
c. Restoring the tablespace to its normal state
2. Backup of the archived redo log files, which consists of
a. Recording which files are in the archived redo log destination directory
b. Backing up the archived redo log files, then (optionally) deleting or compressing them
3.
Backup of the control file via the alter database backup controlfile command.
NOTE
The online backup process is automated via the RMAN utility.
You should create a script to perform the backups. The script should run at the operating
system level, with SQLPLUS commands executed for Steps 1a, 1c, and 3.
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:40 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Chapter 40: The Hitchhiker’s Guide to Database Administration
825
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 40
Blind Folio 40:825
When the datafiles are being backed up, you may back them up directly to tape or to disk.
If you have enough disk space available, choose the latter option, since it will greatly reduce the
time necessary for the backup procedures to complete.

Recovery Manager
Beginning in Oracle8.0, a Recovery Manager toolset called RMAN has been supplied to enable
you to back up and recover your databases in an automated manner using either a command-line
mode or the Recovery Manager from within the Oracle Enterprise Manager. You can use either
approach to back up, restore, and recover database files.
Recovery Manager keeps track of backups either through a Recovery Catalog or by placing
the required information into the control file for the database being backed up. Recovery
Manager adds new backup capabilities that are unavailable in the other Oracle backup utilities.
There are four components within the Recovery Manager: the RMAN executable, one or more
target databases, the Recovery catalog database, and the Media management software. The only
components that you must have are the RMAN executable and a target database. Since RMAN
automatically stores its metadata in the target database’s control file, you do not have to have a
recovery catalog.
The most significant new capability provided via Recovery Manager is the ability to perform
incremental physical backups of datafiles. During a full (called a
level 0
) datafile backup, all of
the blocks ever used in the datafile are backed up. During a cumulative (
level 1
) datafile backup,
all of the blocks used since the last full datafile backup are backed up. An incremental (
level 2
)
datafile backup backs up only those blocks that have changed since the most recent cumulative
or full backup. You can define the levels used for incremental backups.
The ability to perform incremental and cumulative backups of datafiles may greatly improve
the performance of backups. The greatest performance improvements will be realized by very
large databases in which only a small subset of a large tablespace changes. Using the traditional
backup methods, you would need to back up all of the datafiles in the tablespace. Using
Recovery Manager, you only back up the blocks that have changed since the last backup.

During database recovery using Recovery Manager, you need to know which files are current,
which are restored, and the backup method you plan to use. If you use the recover catalog,
Recovery Manager stores its catalog of information in an Oracle database—and you need to back
up that database or else you may lose your entire backup and recovery catalog of information.
Recovery Manager is only used by DBAs, who need to make the decisions regarding the
Recovery Manager architecture for your environment (for example, deciding on the location of
the recovery catalog). You should work with your DBA to understand the recovery options in
use and their implications for database availability and recovery time.
Performing a Backup with Oracle Enterprise Manager (OEM)
To perform any level backup using the OEM tool, connect to the OEM Server Manager console,
select the appropriate database and right-click to bring up the database options. From the
database options, select the Backup option from the Backup Manager menu. The Backup Wizard
will activate.
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:40 PM
Color profile: Generic CMYK printer profile
Composite Default screen
To perform a backup operation, the target database must be running and available. After
the initial Welcome screen, you are prompted to select a Strategy choice. You can select a
predefined backup strategy or customize your own backup strategy. OEM displays the Backup
Frequency options screen with three choices:
1. A Decision Support System (DSS) with a backup frequency of once a week
2. A moderately updated system (OLTP) that is not very large with a backup frequency
of every day
3. A frequently updated, medium to large database with a backup frequency of full
backups weekly and incremental backups nightly
The default option is a DSS system backed up once a week on Sunday. Once you have
selected a strategy, you will be prompted for the time to execute the backup, and the databases
to back up. To perform an immediate backup, you can choose the Customize option from the
initial Strategy screen.

Where to Go from Here
In this chapter, you’ve seen a high-level overview of the topics that production DBAs deal with
every day. In addition to the topics discussed here, DBAs monitor databases, tune databases, install
software, maintain database connectivity, and many other tasks. If you are interested in learning
more about those tasks, see your Oracle documentation set or the
Oracle9i DBA Handbook
(Oracle Press, 2001). The more developers understand about database administration, the more
likely they are to build applications that take advantage of the database’s inherent capabilities.
826
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 40
Blind Folio 40:826
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:40 PM
Color profile: Generic CMYK printer profile
Composite Default screen
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:827
CHAPTER
41
The Hitchhiker’s Guide
to XML in Oracle
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:41 PM
Color profile: Generic CMYK printer profile
Composite Default screen

X
ML (eXtensible Markup Language) is a standardized syntax for describing hierarchical
data. Rather than being a programming language, XML is a universal format for
structured documents and data. Its tag-based syntax will be familiar to those
familiar with HTML (HyperText Markup Language) and gives it the flexibility to
handle complex data. Whereas HTML tells a Web browser how to present data,
XML tells applications what the data means.
XML is well suited to solving data interchange problems among heterogeneous systems;
database-resident data is easily accessed, converted, and stored. In this chapter, you will see an
overview of the XML access methods available in Oracle9i. XML and its toolsets are evolving;
see for the most current information.
NOTE
Thanks to Mike Holder of TUSC for his contributions to this chapter.
Document Type Definitions,
Elements, and Attributes
In XML, application-specific tags or “elements” wrap around the data they describe. The
syntax for these tags is defined in a special kind of XML document called a Document Type
Definition (DTD). The DTD defines the structure for a valid XML document. The structure is
strictly hierarchical.
Each XML document is an instantiation of an “infoset”—the abstract data model consisting
of a document and its information items. Information items are mostly elements, attributes, and
content. For example, an XML infoset may contain the following:
<book>
<title>MY LEDGER</title>
<chapter num="1">
<title>Beginning</title>
<text>&chapter1;</text>
</chapter>
</book>
In this example, the tags <book> and </book> define the starting and ending points of the

infoset. The XML document describes a book named “MY LEDGER”. That book has chapters,
and the first chapter’s title is “Beginning”. The text of the chapter is not stored inside the XML
document; instead, a pointer is created to an external file.
In addition to being a tag in the file, “title” is an element. It has content, in this example,
“MY LEDGER”. As shown in this example, you can set the content of elements by providing
values between tags (for the title) or within the tag (as in the chapter number setting). Elements
can contain content, child elements, or both, or they may be empty. For data interchange, you
should avoid creating elements that contain both content and child elements. To create an
empty element, its tag would be in the format:
<name/>
828
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:828
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:41 PM
Color profile: Generic CMYK printer profile
Composite Default screen
NOTE
Element names are case-sensitive.
Each element has exactly one parent, and a parent can have any number of children. The
strict hierarchical nature of XML means that if an element starts within another element (such as
“chapter” within “book”), its ending tag must precede the ending tag for the parent element.
As shown in the book example, elements have attributes. For example, the chapter element
has an attribute named
num
. The attribute value is enclosed in double quotes:
<chapter num="1">

NOTE
Like element names, attribute names are case-sensitive.
In general, applications use element attributes for specific items (such as the chapter number)
and element content for the bulk of the data (in this case, the chapter text).
An XML document is said to be well-formed if the following conditions are met:

Every start tag has a matching end tag.

Elements do not overlap.

There is one root element.

Attribute values are always within quotes.

An element cannot have two attributes within the same name.

Comments and processing instructions do not appear inside tags.

There are no unescaped < or & signs in an element’s or attribute’s character data.
These are the basic syntax rules. If an XML document conforms to these rules, it may still
not be valid. To be valid, the XML document must conform to the rules of a Document Type
Definition (DTD). The DTD is a formal way of describing what elements and entities may appear
in an XML document, and what each element’s contents and attributes are.
For example, consider the following XML document.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CustomerList SYSTEM "Example1.dtd">
<CustomerList>
<Customer preferredCustomer="">
<ID>12345</ID>
<Address>

<Name>TUSC</Name>
<Street>377 E BUTTERFIELD RD</Street>
<City>LOMBARD</City>
<State>IL</State>
<Country>USA</Country>
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
829
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:829
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:42 PM
Color profile: Generic CMYK printer profile
Composite Default screen
<ZIP_CODE>60148</ZIP_CODE>
<PHONE>630-960-2909</PHONE>
</Address>
<CreditRating>EXCELLENT</CreditRating>
<SalesRepID></SalesRepID>
<RegionID>5</RegionID>
<Comments>THIS IS A TEST XML DOCUMENT</Comments>
<ShippingMethod>M</ShippingMethod>
</Customer>
</CustomerList>
The first line is an XML declaration, which starts with “<?” and ends with “?>“:
<?xml version="1.0" encoding="UTF-8"?>
The
version
attribute should be set to 1.0 for now. The

encoding
attribute is optional; its default
value is UTF-8. You can also set a third attribute,
standalone
. In this case, the XML document is not
standalone; it has a related DTD, as specified in the second line:
<!DOCTYPE CustomerList SYSTEM "Example1.dtd">
The related DTD file Example1.dtd for this example is shown in the following listing:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT CustomerList (Customer*)>
<!ELEMENT Customer (ID, Address, CreditRating*, SalesRepID*,
RegionID, Comments*, ShippingMethod)>
<!ATTLIST Customer preferredCustomer CDATA #IMPLIED>
<!ELEMENT ID (#PCDATA)>
<!ELEMENT Address (Name, Street*, City, County,
State, Country, ZIP_CODE, PHONE)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Street (#PCDATA)>
<!ELEMENT City (#PCDATA)>
<!ELEMENT County (#PCDATA)>
<!ELEMENT State (#PCDATA)>
<!ELEMENT Country (#PCDATA)>
<!ELEMENT ZIP_CODE (#PCDATA)>
<!ELEMENT PHONE (#PCDATA)>
<!ELEMENT CreditRating (#PCDATA)>
<!ELEMENT SalesRepID (#PCDATA)>
<!ELEMENT RegionID (#PCDATA)>
<!ELEMENT Comments (#PCDATA)>
<!ELEMENT ShippingMethod (#PCDATA)>
The DTD is analogous to the control file specifications for external tables. It tells applications

what they will find in the XML document—the element names and the hierarchy of elements. An
XML document can have only one DTD.
The syntax for the element declarations is
<!ELEMENT
element_name
(
content_model
)>
830
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:830
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:42 PM
Color profile: Generic CMYK printer profile
Composite Default screen
where
content_model
specifies what children an element can or must have and the order they
are in. The simplest content model is #PCDATA, which says that the element can contain only
parsed character data. For example:
<!ELEMENT Name (#PCDATA)>
In this example, the CustomerList element contains zero or more “Customer” elements, as
indicated by the * suffix:
<!ELEMENT CustomerList (Customer*)>
The allowable suffixes are
* Permits zero or more occurrences
+ Permits one or more occurrences

? Permits zero or one occurrences
As shown in the Address element specification, you can specify a sequence of multiple
elements by separating them with commas:
<!ELEMENT Address (Name, Street*, City, County,
State, Country, ZIP_CODE, PHONE)>
You can provide multiple options within the specification, separated by the vertical bar (|)
character. For example, a point on a two-dimensional graph may be specified via its horizontal
and vertical measurements or its distance and angle from the center:
<!ELEMENT Point ((x,y) | (distance, angle))>
For real-world applications, DTDs can quickly become very complex. You can have attribute
lists, external references, entity attributes, IDs, conditional inclusions, and other structures within
your DTD. Refer to XML documentation for a thorough review of DTD structures and options.
NOTE
Before creating a DTD for a standard business operation, see
if one is already available for your purpose. Web sites such as
provide many examples of DTDs.
These registries provide a valuable resource for the documentation of
industry standard DTDs and their components.
XML Schema
The XML Schema specification is an alternative to DTDs. It includes data typing, which is
particularly helpful when working with relational databases. Whereas DTDs are not extensible
(they’re just control files), XML Schema is extensible in the following ways:

Parts of schemas can be reused in other schemas.

Complex structures can be reused in other schemas.
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
831
ORACLE Series TIGHT / Oracle9
i

: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:831
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:43 PM
Color profile: Generic CMYK printer profile
Composite Default screen

Derived datatypes can be created based on existing datatypes.

A single document instance can reference multiple schemas.
Within XML Schema, elements are declared using xsd:element, as shown in the following listing:
<xsd:element name="Date">
The element’s datatype can be declared via the
type
attribute:
<xsd:element name="Date" type="date">
You can specify the minimum and maximum number of occurrences for the element via the
minOccurs
and
maxOccurs
attributes:
<xsd:element name="Date" type="date" minOccurs="0" maxOccurs="1">
Built-in XML Schema types include primitive types (such as string, Boolean, number,
float, date, time, and datetime) and derived types (such as normalizedString, integer, token,
and language). The full list of types can be found at />You can create and name complex types, just as you can create abstract datatypes in Oracle.
The following code creates the “Address” type:
<xsd:complexType name="Address">
<xsd:sequence>
<xsd:element name="Street1"/>
<xsd:element name="Street2"/>

<xsd:element name="City"/>
<xsd:element name="State"/>
<xsd:element name="Zip"/>
</xsd:sequence>
</xsd:complexType>
You can then refer to the “Address” complex type when defining your elements:
<xsd:element name="mailingAddress" type="Address"/>
<xsd:element name="billingAddress" type="Address"/>
If you are declaring a content model for a single element, use an anonymous type, as shown
in the following listing.
<xsd:element name="Name">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="First"/>
<xsd:element name="MiddleInitial"/>
<xsd:element name="Last"/>
</xsd:sequence>
</xsd:complexType
</xsd:element>
832
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:832
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:43 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Attributes are declared using xsd:attribute, as shown in the following example:

<xsd:attribute name="paid" type="boolean"/>
You can create attributes within a complex type:
<xsd:element name="Invoice">
<xsd:complexType>
<xsd:attribute name="paid" use="optional" default="True"/>
</xsd:complexType>
</xsd:element>
In addition to creating attributes, you can create attribute groups and model groups. Model
groups are groups or element definitions, named for reuse. The “group” element must be a
top-level schema component (a child of the “schema” element). For example, the following
listing shows the creation of a MealOptions group, referenced by the “FlightDinner” element.
<xsd:element name="FlightDinner">
<xsd:sequence>
<xsd:element ref="Name"/>
<xsd:group ref="MealOptions"/>
</xsd:sequence>
</xsd:element>
<xsd:group name="MealOptions">
<xsd:choice>
<xsd:element name="Fish" type="Meal"/>
<xsd:element name="Meat" type="Meal"/>
<xsd:element name="Vegetarian" type="Meal"/>
</xsd:choice>
</xsd:group>
Attributes are commonly grouped together if elements often use the same set of attributes.
This is similar to the approach described in Part IV of this book, in which common attributes
were combined to form new datatypes. For example, the following definition for a “Product”
element uses an attribute group named
productDetails
. Other elements can reuse this same

attribute group, improving your ability to enforce a standardized representation of this data.
<xsd:element name="Product">
<xsd:complexType>
<xsd:attributeGroup ref="productDetails"/>
</xsd:complexType>
</xsd:element>
<xsd:attributeGroup name="productDetails">
<xsd:attribute name="productID" use="required" type="xsd:ID"/>
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="description" use="required" type="xsd:string"/>
<xsd:attribute name="unit" type="xsd:positiveInteger"/>
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
833
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:833
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:44 PM
Color profile: Generic CMYK printer profile
Composite Default screen
<xsd:attribute name="price" use="required" type="xsd:decimal"/>
<xsd:attribute name="stock" type="xsd:integer"/>
</xsd:attributeGroup>
You can enforce uniqueness within a document instance by using xsd:unique:
<xsd:unique name="uniqueProductID">
<xsd:selector xpath="tc:Product/"/>
<xsd:field xpath="tc:@productID"/>
</xsd:unique>
Uniqueness is declared at the same level as the complex type definition for the “Product”

element. The
tc:
namespace is for the schema we are creating and is declared in the xsd:schema
element. The xsd:selector value specifies the elements to constrain (the “Product” elements), and
xsd:field specifies the attribute to constrain (productID).
You can use xsd:key and xsd:keyref to create references between elements. For example, you
can create a “Customer” element and then reference it from multiple “Invoice” elements:
<xsd:key name="customerID">
<xsd:selector xpath="tc:SalesData/"/>
<xsd:field xpath="tc:Customer/@CustID"/>
</xsd:key>
<xsd:keyref name="item" refer="customerID">
<xsd:selector xpath="tc:SalesData/"/>
<xsd:field xpath="tc:Invoice/@CustID"/>
</xsd:keyref>
To allow an element to be NULL, use the
nillable
attribute:
<xsd:element name="FlightDinner" nillable="true"/>
Using XSU to Select, Insert,
Update, and Delete XML values
You can use Oracle’s XML-SQL Utility (XSU) to convert the result of a SQL query to XML. XSU
supports dynamic generation of DTDs and the insertion of XML into database tables. You can
also use XSU to update or delete rows from database objects.
You can access XSU via Java and PL/SQL APIs (application programming interfaces). The XSU
Java classes are part of the Oracle kernel software. The PL/SQL API is a wrapper that publishes the
Java classes to PL/SQL (see Chapter 36). Because the XSU classes are stored in the database, you
can write new stored procedures to directly access XSU’s Java classes. Since there is a PL/SQL API
available, XSU’s functionality can be accessed directly through SQL.
For example, you can generate the XML version of the RATING table via the XSU PL/SQL

procedures. The following listing creates a procedure named PRINTCLOBOUT that will be called
as part of the data output process. The data will be read in as a CLOB.
834
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:834
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:44 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
835
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:835
create or replace procedure PRINTCLOBOUT(result IN OUT NOCOPY CLOB)
is
xmlstr varchar2(32767);
line varchar2(2000);
begin
xmlstr := dbms_lob.SUBSTR(result,32767);
loop
exit when xmlstr is null;
line := substr(xmlstr,1,instr(xmlstr,chr(10))-1);
dbms_output.put_line('| '||line);
xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
end loop;

end;
Now that the PRINTCLOBOUT procedure exists, run the following anonymous PL/SQL
block. This block queries the RATING table, so that table must be accessible from your schema
(see the accompanying CD-ROM):
declare
queryCtx DBMS_XMLquery.ctxType;
result CLOB;
begin
set up the query context
queryCtx := DBMS_XMLQuery.newContext('select * from rating');
get the result
result := DBMS_XMLQuery.getXML(queryCtx);
Now you can use the result to put it in tables/send as messages
printClobOut(result);
DBMS_XMLQuery.closeContext(queryCtx); you must close the query
end;
The result is the RATING table, formatted with XML tags:
| <?xml version = '1.0'?>
| <ROWSET>
| <ROW num="1">
| <RATING>1</RATING>
| <RATINGDESCRIPTION>ENTERTAINMENT</RATINGDESCRIPTION>
| </ROW>
| <ROW num="2">
| <RATING>2</RATING>
| <RATINGDESCRIPTION>BACKGROUND INFORMATION</RATINGDESCRIPTION>
| </ROW>
| <ROW num="3">
| <RATING>3</RATING>
| <RATINGDESCRIPTION>RECOMMENDED</RATINGDESCRIPTION>

| </ROW>
| <ROW num="4">
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:44 PM
Color profile: Generic CMYK printer profile
Composite Default screen
| <RATING>4</RATING>
| <RATINGDESCRIPTION>STRONGLY RECOMMENDED</RATINGDESCRIPTION>
| </ROW>
| <ROW num="5">
| <RATING>5</RATING>
| <RATINGDESCRIPTION>REQUIRED READING</RATINGDESCRIPTION>
| </ROW>
| </ROWSET>
PL/SQL procedure successfully completed.
Insert, Update, and Delete Processing with XSU
To insert a document into a table or view, use the DBMS_XMLSave package. XSU will parse the
document and create an insert statement that inserts the values into all the columns of the table
or view. An absent element is treated as a NULL value.
create or replace procedure INSPROC(xmlDoc IN CLOB,
tableName IN VARCHAR2) is
insCtx DBMS_XMLSave.ctxType;
rows number;
begin
insCtx := DBMS_XMLSave.newContext(tableName); get the context
rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); insert the doc
DBMS_XMLSave.closeContext(insCtx); close the handle
end;
You can now pass in XML documents as CLOB input values to the INSPROC procedure,
along with the table name. INSPROC will take the XML document and insert its values into the

table. Updates can be executed via calls to a separate procedure, UPDATEPROC, shown in the
following listing.
create or replace procedure UPDATEPROC ( xmlDoc IN clob) is
updCtx DBMS_XMLSave.ctxType;
rows number;
begin
updCtx := DBMS_XMLSave.newContext('RATING'); get context
DBMS_XMLSave.clearUpdateColumnList(updCtx); clear settings
DBMS_XMLSave.setKeyColumn(updCtx,'RATING'); set RATING as key
rows := DBMS_XMLSave.updateXML(updCtx,xmlDoc); update
DBMS_XMLSave.closeContext(updCtx); close context
end;
In this example, the Rating column is the key column used for the update’s where clause:
DBMS_XMLSave.setKeyColumn(updCtx,'RATING'); set RATING as key
The new values are passed in as an XML document in CLOB format, and the RATING table
values are updated based on the contents of the XML document.
836
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:836
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:45 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Deletes function in much the same way. The following procedure takes an XML document as
its input, establishes the Rating column as the key for the RATING table, and performs the delete
based on the key values in the input document. Note that newContext takes the table name RATING
as its input value, while setKeyColumn takes the key column name (which in this case happens

to also be Rating).
create or replace procedure DELETEPROC(xmlDoc IN clob) is
delCtx DBMS_XMLSave.ctxType;
rows number;
begin
delCtx := DBMS_XMLSave.newContext('RATING');
DBMS_XMLSave.setKeyColumn(delCtx,'RATING');
rows := DBMS_XMLSave.deleteXML(delCtx,xmlDoc);
DBMS_XMLSave.closeContext(delCtx);
end;
XSU and Java
If you prefer, you can perform the XSU DML operations via calls to Java classes instead
of the PL/SQL procedures. In place of the DBMS_XMLQuery package, you should execute
the oracle.xml.sql.query.OracleXMLQuery class. In place of the DBMS_XMLSave package,
use oracle.xml.sql.dml.OracleXMLSave.
For example, the Oracle-provided sample Java program for XML queries is customized
slightly in the following listing. It relies on connection management in a fashion very similar
to that shown in the SQLJ and JDBC examples (see Chapter 35). The program imports the
oracle.xml.sql.query.OracleXMLQuery class, enabling it to get the XML string; Java’s
System.out.println method is then called to display the output.
import oracle.xml.sql.query.OracleXMLQuery;
import java.lang.*;
import java.sql.*;
// class to test the String generation!
class testXMLSQL {
public static void main(String[] argv)
{
try{
// create the connection
Connection conn = getConnection("practice","practice");

// Create the query class.
OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from rating");
// Get the XML string
String str = qry.getXMLString();
// Print the XML output
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:837
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
837
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:45 PM
Color profile: Generic CMYK printer profile
Composite Default screen
System.out.println(" The XML output is:\n"+str);
// Always close the query to get rid of any resources
qry.close();
}catch(SQLException e){
System.out.println(e.toString());
}
}
// Get the connection given the user name and password !
private static Connection getConnection(String username,
String password)
throws SQLException
{
// register the JDBC driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
// Create the connection using the OCI8 driver

Connection conn =
DriverManager.getConnection("jdbc:oracle:oci8:@or90",username,password);
return conn;
}
}
For details on SQLJ, connection management, and Java, see Part V of this book.
Customizing the Query Process
You can create your own procedures to simplify the interaction with the DBMS_XMLQuery and
DBMS_XMLSave packages. For example, the following listing creates a function named GET_XML.
GET_XML will select the rows from the table and display it in XML format.
create function GET_XML (in_SQL varchar2)
return CLOB
is queryCtx DBMS_XMLQuery.ctxType;
result CLOB;
begin queryCtx := DBMS_XMLQuery.newContext(in_SQL);
result := DBMS_XMLQuery.getXML(queryCtx);
DBMS_XMLQuery.closeContext(queryCtx);
return result;
end;
The data will be returned in CLOB format, so you can use the set long command to set the
maximum display length (the default is 80 characters). You can call GET_XML from within SQL
queries, as shown in the following listing.
set pagesize 100 long 2000
select GET_XML('select * from category') from DUAL;
838
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:838

P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:45 PM
Color profile: Generic CMYK printer profile
Composite Default screen
GET_XML('SELECT*FROMCATEGORY')

<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<CATEGORYNAME>ADULTREF</CATEGORYNAME>
<PARENTCATEGORY>ADULT</PARENTCATEGORY>
<SUBCATEGORY>REFERENCE</SUBCATEGORY>
</ROW>
<ROW num="2">
<CATEGORYNAME>ADULTFIC</CATEGORYNAME>
<PARENTCATEGORY>ADULT</PARENTCATEGORY>
<SUBCATEGORY>FICTION</SUBCATEGORY>
</ROW>
<ROW num="3">
<CATEGORYNAME>ADULTNF</CATEGORYNAME>
<PARENTCATEGORY>ADULT</PARENTCATEGORY>
<SUBCATEGORY>NONFICTION</SUBCATEGORY>
</ROW>
<ROW num="4">
<CATEGORYNAME>CHILDRENPIC</CATEGORYNAME>
<PARENTCATEGORY>CHILDREN</PARENTCATEGORY>
<SUBCATEGORY>PICTURE BOOK</SUBCATEGORY>
</ROW>
<ROW num="5">
<CATEGORYNAME>CHILDRENFIC</CATEGORYNAME>

<PARENTCATEGORY>CHILDREN</PARENTCATEGORY>
<SUBCATEGORY>FICTION</SUBCATEGORY>
</ROW>
<ROW num="6">
<CATEGORYNAME>CHILDRENNF</CATEGORYNAME>
<PARENTCATEGORY>CHILDREN</PARENTCATEGORY>
<SUBCATEGORY>NONFICTION</SUBCATEGORY>
</ROW>
</ROWSET>
Using XMLType
As of Oracle9i, you can use XMLType as a datatype in your tables. XMLType can be used to store
and query XML data in the database. As a type, XMLType has member functions (see Chapter 30)
to access, extract, and query XML data using a class of operations known as Xpath expressions.
The SYS_XMLGEN, SYS_XMLAGG, and DBMS_XMLGEN packages create XMLType values from
existing object-relational data. When you designate a column as using the XMLType datatype,
Oracle will store the data internally in a CLOB datatype.
The following listing shows the creation of a table using the XMLType datatype:
create table MY_XML_TABLE
(Key1 NUMBER,
Xml_Column SYS.XMLTYPE);
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
839
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:839
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:46 PM
Color profile: Generic CMYK printer profile
Composite Default screen

840
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:840
If you describe the table, you will see its columns:
desc MY_XML_TABLE
Name Null? Type

KEY1 NUMBER
XML_COLUMN SYS.XMLTYPE
If you increase the describe depth, you will see the member functions for the XMLType
column as well:
set describe depth 5
desc MY_XML_TABLE
Name Null? Type

KEY1 NUMBER
XML_COLUMN SYS.XMLTYPE
METHOD

STATIC FUNCTION CREATEXML RETURNS XMLTYPE
Argument Name Type In/Out Default?

XMLDATA CLOB IN
METHOD

STATIC FUNCTION CREATEXML RETURNS XMLTYPE
Argument Name Type In/Out Default?


XMLDATA VARCHAR2 IN
METHOD

MEMBER FUNCTION EXTRACT RETURNS XMLTYPE
Argument Name Type In/Out Default?

XPATH VARCHAR2 IN
METHOD

MEMBER FUNCTION EXISTSNODE RETURNS NUMBER
Argument Name Type In/Out Default?

XPATH VARCHAR2 IN
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:46 PM
Color profile: Generic CMYK printer profile
Composite Default screen
METHOD

MEMBER FUNCTION ISFRAGMENT RETURNS NUMBER
METHOD

MEMBER FUNCTION GETCLOBVAL RETURNS CLOB
METHOD

MEMBER FUNCTION GETSTRINGVAL RETURNS VARCHAR2
METHOD

MEMBER FUNCTION GETNUMBERVAL RETURNS NUMBER

You can now insert values into MY_XML_TABLE by calling XMLType’s CREATEXML method:
insert into MY_XML_TABLE (Key1, Xml_Column)
values (1, SYS.XMLTYPE.CREATEXML
('<book>
<title>MY LEDGER</title>
<chapter num= "1 ">
<title>Beginning</title>
<text>This is the ledger of G.B. Talbot</text>
</chapter>
</book>'));
You can query the data by calling the GETCLOBVAL method. This query
select M.Xml_Column.GETCLOBVAL() as XML_Data
from MY_XML_TABLE M
where Key1 = 1;
returns this data:
XML_DATA

<book>
<title>MY LEDGER</title>
<chapter num="1">
<title>Beginning</title>
<text>This is the ledger of G.B. Talbot</text>
</chapter>
|</book>
NOTE
You can create functional indexes on columns created with the
XMLType datatype to improve performance of queries.
Chapter 41: The Hitchhiker’s Guide to XML in Oracle
841
ORACLE Series TIGHT / Oracle9

i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:841
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:46 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Other Features
This chapter has shown a very high-level view of the interaction of XML data with the Oracle
database. There are many other possibilities, including the use of style sheets for data formatting,
and creating XSQL pages. You can even create text indexes on XMLType columns:
create index XML_INDEX on MY_XML_TABLE (Xml_Column)
indextype is ctxsys.context;
NOTE
See Chapter 24 for further details on text indexes.
Oracle provides additional packages to interact with XML data, including:
DBMS_XMLGEN Converts the results of SQL queries to canonical XML format,
returning them as a CLOB. DBMS_XMLGEN is implemented in
C, and compiled in the database kernel. DBMS_XMLGEN is
similar in functionality to DBMS_XMLQuery package.
SYS_XMLGEN Generates XML within SQL queries. DBMS_XMLGEN and
other packages operate at a query level, giving aggregated
results for the
entire
query. SYS_XMLGEN operates on a
single
argument inside a SQL query and converts the result to XML.
SYS_XMLGEN takes in a scalar value, object type, or an
XMLType instance to be converted to an XML document. It
also takes an optional XMLGenFormatType object to specify

formatting options for the result. SYS_XMLGEN returns an
XMLType.
SYS_XMLAGG Aggregates over a set of XMLTypes. SYS_XMLAGG aggregates
all the input XML documents/fragments and produces a single
XML document by concatenating XML fragments, and adding
a top-level tag that defaults to ROWSET.
Oracle provides utilities to support additional uses, such as oraxml (a command-line interface
to parse an XML document) and oraxsl (a command-line interface used to apply a style sheet on
multiple XML documents). A full discussion of every utility and data access method is beyond the
scope of this book; please see the
Oracle9i Application Developer’s Guide – XML
for additional
options and sample programs.
842
Part VI: Hitchhiker’s Guides
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 41
Blind Folio 41:842
P:\010Comp\Oracle8\521-1\CD\Ventura\book.vp
Friday, July 19, 2002 4:15:47 PM
Color profile: Generic CMYK printer profile
Composite Default screen
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 1
Blind Folio 1:843
PART
VII
Alphabetical Reference

Copyright © 2001, 2002, Oracle Corporation. All rights reserved. This appendix contains
Oracle Corporation User Documentation reproduced herein with permission of Oracle
Corporation, and offers brief summaries of the most common SQL commands used by DBAs.
The commands are arranged alphabetically. This material is extracted from
Oracle9i SQL
Reference
,
SQL*Plus User’s Guide and Reference,
and
Oracle9i Database Utilities Release 1.
P:\010Comp\Oracle8\521-1\CD\Ventura\ch42a.vp
Thursday, July 25, 2002 3:48:42 PM
Color profile: Generic CMYK printer profile
Composite Default screen
T
his chapter contains references for most major Oracle commands, keywords, features,
and functions, with cross-referencing of topics. The reference is intended for use by
both developers and users of Oracle, but assumes some familiarity with the products.
Reading the first four pages of this reference will help you make the most productive
use of the entries.
What This Alphabetical Reference Includes
This alphabetical reference contains entries for virtually every Oracle command in SQL, PL/SQL, and
SQLPLUS, as well as definitions of all relevant terms used in Oracle and SQL. Each command is listed
with its correct format or syntax, an explanation of its purpose and use, the product or products in which
it is used, and important details, restrictions, and hints about it, along with examples to illustrate proper
usage. Topics are in alphabetical order, and are cross-referenced, both within the alphabetical reference
and to preceding chapters in the book.
What This Alphabetical Reference
Does Not Include
This is not a tutorial; it does not explain the screen-oriented development tools. Additionally, there are

a few areas where usage is likely to be so specialized or infrequent that inclusion here did not seem of
much benefit. In these instances, the text refers you to the Oracle manual where you can find the needed
information.
General Format of Entries
Entries in this reference are typically either definitions of terms or descriptions of functions, commands,
and keywords. These are usually structured in seven sections: the keyword, its type, the products in
which it is used, a "See also" cross-reference, the format in which the keyword appears, a description
of its components, and an example of its use. A typical entry looks like the following:
RPAD
SEE ALSO
CHARACTER FUNCTIONS, LPAD, LTRIM, RTRIM, TRIM, Chapter 7
FORMAT RPAD(
string,length
[,'
set'
])
DESCRIPTION
Right PAD. RPAD makes a string a certain length by adding a certain set of
characters to the right. If set is not specified, the default pad character is a space.
EXAMPLE
select RPAD('HELLO ',24,'WORLD') from DUAL;
produces this:
HELLO WORLDWORLDWORLDWOR
The Sections of Each Entry
The KEYWORD usually appears on a line by itself. In some cases a brief definition follows. If a
keyword has more than one definition, either in different Oracle tools or in different Oracle versions,
the keyword will be followed by a brief qualifier in order to indicate that more than one listing exists
for this keyword.
844
Part VII: Alphabetical Reference

ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 1
Blind Folio 1:844
P:\010Comp\Oracle8\521-1\CD\Ventura\ch42a.vp
Thursday, July 25, 2002 3:48:44 PM
Color profile: Generic CMYK printer profile
Composite Default screen
SEE ALSO suggests other topics that are closely related to the keyword, or gives the chapter or
chapters in the book that give detailed descriptions of how the keyword is used in practice. Occasionally
you will be referred to the Oracle manual or other reference book that contains detail beyond the scope
of this reference.
FORMAT generally follows the notation of Oracle manuals, with all SQL and other keywords
in uppercase. In actual use, these must be entered exactly as they are shown (except that case is
irrelevant). Variables and variable parameters are shown in lowercase
italic.
This indicates that some
appropriate value should be substituted. When parentheses are shown, they must be entered where
they appear, just as are words shown in uppercase.
Standard Usages for Variables
Some standard usages for variables follow:
This Variable Indicates
Column
The name of a column
Database
The name of a database
Link
The name of a link in Oracle Net
Password
A password

Segment
The name of a segment
Table
The name of a table
Tablespace
The name of a tablespace
User
The name of a user or owner
View
The name of a view
Other Formatting Guidelines
Some other guidelines for formatting follow:

character
means the value must be a single character.

string
typically represents a character column or an expression or column that can be treated
like a CHAR or VARCHAR2 column after automatic data conversion.

value
usually represents a NUMBER column or an expression or column that can be treated
like a NUMBER column after automatic data conversion.

date
usually represents a date column or an expression or column that can be treated like a
date column after automatic data conversion.

integer
must be a whole number, such as -3, 0, or 12.


expression
means any form of a column. This could be a literal, a variable, a mathematical
computation, a function, or virtually any combination of functions and columns whose final
result is a single value, such as a string, a number, or a date.

Occasionally other notation is used as well, such as
condition
or
query
. This is explained or
is apparent in context.

Optional items are enclosed in square brackets, as in [user.], meaning that
user
is not
necessarily required.
Other Formatting Guidelines
845
ORACLE Series TIGHT / Oracle9
i
: The Complete Reference / Loney, Koch / 222521-1 / Chapter 1
Blind Folio 1:845
P:\010Comp\Oracle8\521-1\CD\Ventura\ch42a.vp
Thursday, July 25, 2002 3:48:44 PM
Color profile: Generic CMYK printer profile
Composite Default screen

×