Type the following command, replacing pwd with the password for the SYSTEM user and replacing name with your appropriatenetwork name, and press Enter.. Type the following SQL*Plus comman
Trang 120 1.6 SQL Tools
Before you begin the following steps, you will need these two pieces ofinformation about your database:
The database name or network name If you are running the
database on your own computer, this is the name you gave the base when it was created If you are not sure what you named it, go
data-to a command prompt (see step 1 data-to learn how) and then type thiscommand:
lsnrctl status
Look for a line that begins like this The word in quotation marks
is your database name In this example, the database SID name isOLTP
Instance "oltp", status READY,
If you are running from a client computer and using a remotedatabase on the network, you must use the network name defined inyour local Oracle Net configuration The configuration file namedTNSNAMES.ORA has all of the network names available to you.The file is located in $ORACLE_HOME/network/admin directory.Here is an example of the text found in the TNSNAMES.ORA filefor the OLTP network name:
OLTP = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 1300server) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oltp)))
Trang 21.6 SQL Tools 21
The password for the users named SYS and SYSTEM The Oracle
Database Configuration Assistant in Oracle Database 10g allows
set-ting of SYS and SYSTEM passwords to the same value
If you are running a database on your own computer or on a databaseserver, you can reach the database directly by omitting the database name.When you omit the name, Oracle uses the bequeth protocol and the cur-rent $ORACLE_SID variable setting to access the database In Windowsthe $ORACLE_SID variable is set in the registry, and on UNIX or Linux
in a user or root profile Figure 1.11 shows a Win2K registry location.When you use the database name, Oracle uses the transmission controlprotocol (TCP) Follow these steps to start up SQL*Plus Command Lineand run an SQL command:
Note: The steps here, and throughout the book, use the sample tables and
data created especially for this book Appendix A contains instructions forlocating and installing all of the sample tables
1 Go to a command-line prompt on your computer If you areusing Windows, click on Start/Programs/Accessories/CommandPrompt A window appears with a blinking cursor This is your
Figure 1.11
Win2K Registry ORACLE_SID Variable.
Trang 3Ter-2 Type the following command, replacing pwd with the password for the SYSTEM user and replacing name with your appropriate
network name, and press Enter
sqlplus system/pwd@name
3 You will see status information about SQL*Plus and the databaseand a message stating you are connected Then your display’sprompt changes to “SQL>”, indicating that you are now inSQL*Plus Figure 1.12 shows an example of the commandprompt window after starting up SQL*Plus
4 Type the following SQL*Plus commands, and press Enter aftereach line These set up the column width displayed for the querythat follows (More on SQL*Plus commands in Chapter 8.)
COL PRODUCT FORMAT A35 COL VERSION FORMAT A15 COL STATUS FORMAT A15
5 Type the following query and press Enter:
Figure 1.12
SQL*Plus Command Line in
Windows 2000.
Trang 41.6 SQL Tools 23
SELECT * FROM PRODUCT_COMPONENT_VERSION;
The asterisk represents all of the columns Thus all columns aredisplayed in this query Figure 1.13 shows the results The actualdata may be different, depending on the shape of your Oracle
One of the disadvantages of using the command-line mode of SQL*Plus
is the inability to use the mouse to correct your typing You must erase usingthe backspace key Table 1.1 shows the editing commands you can use
An advantage of the command-line mode is the ability to add ters to the sqlplus command For example, you can run a script immedi-ately upon startup, or start SQL*Plus without logging into any databaseinstance (this is useful for issuing SQL commands for starting and stoppingthe database)
parame-SQL*Plus does have a line editor built into it that you can use instead ofstarting up an editor
Figure 1.13
SQL*Plus SQL Commands Return
Instant Results.
Trang 524 1.6 SQL Tools
Next, you will look at the Windows-like SQL*Plus tool
1.6.2 SQL*Plus in Windows Mode
This version of SQL*Plus gives you a Windows-like interface with a fewenvironmental options However, it still requires you to type a single line at
a time
To try out SQL*Plus in Windows mode, follow these steps:
1 If you are using a Windows operating system, start the tool byclicking Start/Programs/Oracle – Orahome10/Application Devel-opment/SQL*Plus If you are using another operating system, go
to a command-line prompt, type sqlplusw, and press Enter
You will see a Log On window appear You must log on withvalid credentials now
2 Type SYSTEM in the User Name box, the current password forSYSTEM in the Password box, and your database name in theHost String box Figure 1.14 shows the Log On window with theinformation filled in Notice that the password appears as a line ofasterisks This is to keep your password private
3 Click OK to log in The SQL*Plus window appears Just likethe command-line version, you see status information and get
Table 1.1 SQL*Plus Line Editing Commands.
c/old/new Change old to new characters in current
line.
l or list List the SQL in the buffer.
del n or del * or del n m Delete line n in the SQL buffer, or delete
the current line (*) or delete lines n through m.
a text or append text Add text to the end of the current line.
i or input or i text or input text Insert a new line after the current line
Add text to the line, if text is specified.
Trang 6DESC DBA_USERS
5 The screen shows the names and datatypes of all the columns inthis view This is very useful when you are about to write an SQLcommand and you need a quick reminder of the exact columnnames in a table Now type this query and press Enter after eachline Notice that the prompt changed from “SQL>” to “2” on thesecond line This indicates that SQL*Plus knows you have started
a command and you are continuing it on the next line The colon at the end of the second line signals to SQL*Plus that thecommand is complete and should be immediately executed
semi-SELECT USERNAME, ACCOUNT_STATUS, CREATED FROM DBA_USERS;
6 The results scroll by, and you can use the scroll bar on the rightside of the window to move up or down and view the results Fig-ure 1.15 shows the results from the query The column headings
Figure 1.14
Log into Your Database as a Valid User.
Trang 726 1.6 SQL Tools
and report feedback are standard parts of every mode ofSQL*Plus; however, the scroll bar and the menu are features ofthe Windows mode and not of the command-line mode Someoperating systems will allow configuration changes to allow addi-tion of scroll bars to command-line windows
7 Click on Edit in the top menu and invoke the editor A windowappears with an editing program and the text of the query youwrote ready for editing In Windows, the default editor is Note-pad In UNIX, Linux, and other operating systems, the defaulteditor can be configured in a user profile
8 The editor can be used to change the command you created whileworking in SQL*Plus You can retrieve files with SQL commands
in them using the File/Open command on the menu Selectingthe File/Run command from the menu will execute the mostrecent SQL command Modify the query by removing the CRE-ATED column from the query
9 Save the file and exit the editor The modified query now appears
on the screen, ready to run if you choose Figure 1.16 shows whatyour SQL*Plus screen should look like now
10 Before running the command, select File/Spool/Spool File from
the menu A window opens in which you can select the file nameand location This file will contain everything you type andSQL*Plus returns from the moment you return to SQL*Plus
Trang 81.6 SQL Tools 27
until you turn it off, or until you exit SQL*Plus This is a handyway to record your work In addition, in Chapter 8, you will findout how to write reports using this spooling technique Navigate
to a directory of your choosing, such as C:\TEMP in Windows,and then type “testing” as the file name and click Save The filewill automatically receive a suffix of “.LST” on Windows and of
“.lis” on UNIX and other operating systems
11 Type / (a forward slash) to run the query The forward slash and
the semi-colon both tell SQL*Plus to execute a command Theforward slash must be used alone on a line by itself, whereas thesemi-colon is used at the end of a line of code The semi-colonterminates and submits a single-line SQL command to the data-base The forward slash does the same and additionally compilesand executes blocked sections of PL/SQL code
12 The results scroll into the window as before
13 Type the letter L and press Enter This is the LIST command of
SQL*Plus It displays whatever SQL command is currently in theSQL*Plus buffer
14 Select File/Spool/Spool off to end the spooling of data to the file.
This closes the file that has been receiving data from theSQL*Plus session Your spool file will be empty until this com-mand is executed or you exit SQL*Plus
Figure 1.16
Invoking (Opening) the Editor.
Trang 928 1.6 SQL Tools
15 Exit SQL*Plus by typing EXIT and pressing Enter or by clicking
the X at the top right corner of the window
16 Navigate through Windows Explorer to find the TESTING.LST
file that was spooled in the location you chose If you are usingUNIX, use the cd command or your File Directory window tofind the testing.lst file Open the file with your editor and viewthe results You should see the forward slash (the first thing you
typed after turning on spooling), the query results, the “L”
com-mand, and the query in this file
Spooling is useful for saving queries you develop in SQL*Plus Inaddition, with a few extra commands, you can create a report(with headings, titles, summaries, and so on) from SQL queriesand spool the report to a file ready for printing
17 Close the file
Note: If you make a mistake and press Enter before fixing it, you sometimes
get a line number prompt instead of an SQL prompt This meansSQL*Plus has interpreted your line as the beginning of a command and isexpecting you to complete the command before executing To get out ofthis continuing line mode, type a period (.) alone on a line and press Enter.You will be returned to the SQL prompt so you can begin again
Another form of the SQL*Plus tool can be found within Oracle prise Manager
Enter-1.6.3 SQL*Plus Worksheet
The Oracle Enterprise Manager (OEM) is a great set of tools for the base administrator (DBA) The OEM Console gives you a bird’s-eye view ofyour database, or many databases if you have access to more than one TheSQL*Plus Worksheet is a standard part of the OEM suite that is installed
data-when you install Oracle Database 10g (Enterprise, Standard, or Personal
Editions)
To run the worksheet by itself, without going through the OEM sole, follow these instructions:
Trang 10Con-1.6 SQL Tools 29
1 Start SQL*Plus Worksheet from Windows by clicking grams/Oracle – Orahome10/Application Development/SQL*PlusWorksheet If you are using UNIX, Linux, or other platforms, go
Start/Pro-to a command prompt and type:
oemapp worksheet
2 A login window appears The window title is “Oracle EnterpriseManager Login” because the same login window appears for theOEM Console and other OEM tools Select the “Connectdirectly to the database” button
Note: The Management Server is out of the scope of this book.
Type SYSTEM in the User Name box, the current password forSYSTEM in the Password box, and your database name in theService Name box Leave the Connect As box defaulting to “Nor-mal.” Figure 1.17 shows the completed login window; click OK
to log into SQL*Plus Worksheet
3 The SQL*Plus Worksheet window appears The top windowpane
is your area for typing SQL commands The lower pane displaysthe results Click Enter to clear the window
4 Type the following query in the top pane:
SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES;
Figure 1.17
Log into SQL*Plus
Worksheet.
Trang 1130 1.6 SQL Tools
5 Click the Execute icon The icon looks like a lightning bolt and islocated on the left side of the window The results of the queryscroll down on the lower pane Figure 1.18 shows the SQL*PlusWorksheet window at this point
6 Modify the query by changing “FILE_NAME” to BYTES.” Notice that you can edit directly in this tool withoutresorting to an editor
“MAX-7 Run the changed command by clicking the Execute icon again.The results appear in the lower pane
8 Hold your mouse over each of the icons on the left side of thewindow to see the other handy functions available in this tool.For example, the icon just below the Execute icon can list up to
50 previous SQL commands
9 Exit this tool by clicking the X in the top window or typing EXIT
and clicking the Execute icon
The SQL*Plus Worksheet may be the most versatile of the SQL*Plusvariations You may find it easier to work with than SQL*Plus Windows orcommand-line versions and capable of more features than the Web versionfound in the next section
Figure 1.18
SQL*Plus Worksheet Has
Useful
Windows-like Functions.
Trang 121.6 SQL Tools 31
Note: SQL*Plus Worksheet is the tool this book uses to guide you through
learning SQL and SQL*Plus commands Feel free to use the other tools ifyou prefer, although screenshots, when they are used, will display SQL*PlusWorksheet window in most cases
1.6.4 iSQL*Plus
The Web server, called Oracle HTTP Server, can be installed with Oracle
Database 10g The HTTP Server is a miniature application server set up to
run the Web-based tools and programming aids that come with Oracle
Note: If there are problems, see the troubleshooting section in Chapter 8.
Follow these steps to look around with the iSQL*Plus tool:
1 Open your browser
2 Type in this address in the Location box of your browser and
press Enter You must replace mymachine with the actual work name of your computer and mydomain with the actual
net-domain name your computer is in (if none, leave this out) Thedefault port number is 7778, so try that first
http://<mymachine>.<mydomain>:7778/isqlplus
Trang 1332 1.6 SQL Tools
iSQL*Plus presents a login screen, as seen in Figure 1.19 Ifyou do not see this screen, read the section on troubleshooting inChapter 8
3 Type SYSTEM in the Username box, the current password forSYSTEM in the Password box, and your network name in theConnection Identifier box Figure 1.19 shows the boxes filled in
As usual, the password is displayed as a string of asterisks for vacy Click the Login button to go to the main screen
pri-4 The main screen for iSQL*Plus appears Type the following queryinto the box labeled “Enter statements,” and then scroll downand click the Execute button
SELECT VIEW_NAME, TEXT FROM USER_VIEWS;
The SQL command is executed, and the results appear at the tom of the screen Scroll down to view the results, as shown inFigure 1.20
bot-Figure 1.19
iSQL*Plus Gives
Direct Access to the
Database.
Trang 141.6 SQL Tools 33
5 Scroll back to the top of the screen Here are some control tons to explore, as you see in Figure 1.21 The History button issimilar to the SQL History icon in SQL*Plus Worksheet It listsprevious SQL commands and loads them back into the WorkScreen The Preferences button displays a selection of settingsespecially for the browser window, such as the width of the out-put area and whether to place the results in the same browser win-dow (the default) or in a new browser window In addition, thePreferences screen sets SQL*Plus environmental variables (com-mon to all versions of SQL*Plus), such as LINESIZE, ECHO,and HEADINGS Learn more about these settings in Chapter 8
but-6 Click on the Help icon in the top right corner of the window.This brings up a directory of links to commands especially foriSQL*Plus (in the first column), and links to SQL*Plus com-mands that are used for all the versions of SQL*Plus in the sec-ond and third columns Use this if you are not sure how to doSQL*Plus tasks such as setting the number of lines per page on areport, automatically displaying (or suppressing) the SQL com-mand before running the command, and so on
7 Exit this window by clicking the X in the top right corner Themain iSQL*Plus window is still open
Figure 1.20
Query Results Shown as an HTML Table.
Trang 1534 1.7 The MUSIC Schema
8 Exit the iSQL*Plus browser by clicking Logout link, and thenclicking the X in the top right corner when you see the iSQL*Pluslogin screen
Note: See Chapter 8 if you cannot reach the iSQL*Plus login screen
The sample data described here will be used as a basis to write your ownSQL commands as you follow along with step-by-step exercises in everychapter
Figure 1.22 shows the database design structure of the tables, ing their primary keys (the columns that define a unique record) and theircolumns
includ-This schema supports a fictional music studio The music studio keepstrack of the musicians who use the studio and the time they spend in thestudio recording songs Here is a short description of each table:
Figure 1.21
iSQL*Plus Is a
Rich Environment.
Trang 161.7 The MUSIC Schema 35
ARTIST A musician who has either recorded a song or participated
in recording another musician’s song Each artist record has thename, address, and e-mail of the musician Every artist has a uniqueidentification number (ARTIST_ID) assigned when the record wasentered into the database table In addition, a special column calledINSTRUMENTS contains a list of musical instruments the musicianplays This special column is a collection (a list of many values held in
a single column)
SONG The ARTIST_ID column identifies the owner of each song
in the table Each song has a title, recording date, and playing time.The RECORDING column contains the final recorded song in anaudio format, ready to play
MUSICCD and CDTRACK A music CD has two tables for all the
information First, the MUSICCD table holds the CD title, date itwas pressed, and the total playing time of the CD Second, theCDTRACK table contains all the songs for each CD and the order inwhich that song appears on the CD This arrangement of tables
Figure 1.22
The Music Studio
Schema.
Trang 1736 1.7 The MUSIC Schema
allows one song to be included on more than one CD For example,
The Beatles’ song “Let It Be” is on the White Album CD and on The Beatles’ Greatest Hits CD.
GENRE Music CDs can be categorized into genres or types of
music Genres are hierarchical in nature, where one genre can be asubset of another genre
STUDIOTIME When a musician (artist) comes into the studio to
record a song, the studio charges the artist for time spent in the dio This table contains information needed for billing the artist Anartist may have many studio sessions, and each session is a row in theSTUDIOTIME table
stu- GUESTAPPEARANCE A musician seldom records a song alone.
Even though the musician owns the song, he or she often asks othermusicians to collaborate on the recording This table keeps track ofwhich musician (called the guest artist) played on what other musi-cian’s songs
INSTRUMENTATION When a guest artist plays on a song, he or
she plays one or more instruments This table keeps track of whichinstrument each guest artist played on each song For example, Jimplayed drums and sang backup vocals (the voice is considered an
“instrument” in these tables) on Amy’s song Later Amy played guitar
on Jim’s song
INSTRUMENT The instrument table assigns an identifying
num-ber to each instrument The numnum-ber is used in the TATION table So, instruments are actually stored in two differentways in the schema: (1) as a collection in the ARTIST table and (2)
INSTRUMEN-as individual rows in the INSTRUMENT table This is done toillustrate the variety of methods you can use when designing a data-base system
1.7.1 The MUSIC Schema Sales Data Warehouse
The OLTP schema in Figure 1.22 is expanded in Figure 1.23 to create adata warehouse5 structure for CD sales In general, data warehouse tablescan be broken into dimension and fact tables Fact tables contain factssuch as sales record history, and dimensions describe the facts such as thecountries in which sales took place Roughly, dimensions are equivalent toOLTP static tables such as a table of customers Facts are roughly equiva-lent to OLTP transactional tables such as sales transactions A data ware-
Trang 181.7 The MUSIC Schema 37
house data model should in its ideal form be in the structure of a star (starschema) or in a less ideal form of a degraded star schema (snowflake) InFigure 1.23 the SALES table is the fact table, and all other tables aredimensions of those sales entries The schema represented by the entityrelationship diagram is in fact a snowflake schema because of the relation-ship between the CONTINENT and COUNTRY tables This relation-ship is not strictly necessary, but it was useful during the process ofwriting this book
Dimension Tables RETAILER, CONTINENT, and COUNTRY
are all purely dimensional entities of SALES
Partial Dimension Tables The CUSTOMER table could be
con-strued as being a partial fact table describing SALES table entries,apart from the fact that there is a link to the GENRE table in theOLTP structure Links are shown in Figure 1.24
Fact Tables The SALES table is a fact table because it contains facts
about sales or, more simply put, sales transaction records All sions describe SALES such as what country a sale occurred in
dimen-Figure 1.23
The Music Studio
Schema Sales Data
Warehouse.
Trang 192 Oracle Performance Tuning for 9i and 10g (ISBN: 1-555-58305-9)
3 My version of the Normalization is a highly simplified version Ihave twisted Normal Forms deliberately
Trang 20New Features of Oracle SQL
In this chapter:
What are the new features of Oracle SQL in Oracle Database 10g?
What were the new features of Oracle SQL in Oracle Database 9i?
What PL/SQL improvements are there?
How is XML development better supported?
What’s new in Oracle SQL utilities?
This chapter takes a bird’s-eye view of Oracle SQL changes in both cle Database 10g and Oracle Database 9i Without further ado, let’s getstarted with Oracle Database 10g
Oracle Database 10g contains the following SQL and PL/SQL features
2.1.1 Oracle SQL Improvements in Oracle Database 10g
Oracle documentation states that case sensitivity is no longerrequired for filtering and sorting in SQL statements Proving thispoint is a tuning exercise and does not belong in this book
The CONNECT BY clause now allows ancestor-descendant pairs asopposed to only parent-child pairs In other words, pairs can bematched and returned where those pairs are not directly relatedwithin a hierarchy but related from the top to the bottom of a hierar-chy (see Chapter 13)
Chap2.fm Page 39 Thursday, July 29, 2004 9:59 PM
Trang 2140 2.1 New Features in Oracle Database 10g
Object improvements include VARRAY resizing and splitting ofnested table type columns into different tablespaces (see Chapter 16)
A new row timestamp pseudocolumn called ORA_ROWSCN tains a commit point timestamp or system change number (SCN).For updates only, the SCN for a row must be retrieved to ensure that
con-no row change occurred between a row SELECT and subsequentUPDATE
The following new datatypes have been added (see Chapter 16):
BINARY_FLOAT and BINARY_DOUBLE allow 32-bit singleprecision and 64-bit double precision floating-point numbers
SDO_GEORASTER and SI_STILLIMAGE store raster and ital images, respectively (including object characteristics), forobject-relational multimedia storage
dig- A multitude of DDL commands have been altered and enhanced.Most DDL command changes are relevant to database administra-tion and not Oracle SQL
Several SELECT statement and DML command syntax changes havebeen introduced:
MERGE allows insertions, updates, or both Previously, theMERGE command always performed both insertions andupdates Additionally, MERGE can also delete rows from the tar-get table (see Chapter 15)
SELECT can be executed as a flashback or versions query, ing data at a point in time in the past, based on an SCN or times-tamp (see Chapter 13)
retriev- Grouped outer joins allow groupings on data where subset partsmay not exist
Note: Grouped outer joins are omitted from this book because syntaxdocumentation was not available at the time of writing
The SPREADSHEET clause extends the SELECT statement,allowing multiple dimensional array query result output Calcu-lations between resulting rows can be performed much likecross-tabbing or interdimensional data warehouse reporting (seeChapter 11)
Chap2.fm Page 40 Thursday, July 29, 2004 9:59 PM
Trang 222.1 New Features in Oracle Database 10g 41
Note: The SPREADSHEET clause has been renamed to theMODEL clause
Oracle Database 10g has recycle bin technology (see Chapter 18):
Recovering a table from the recycle bin requires use of theFLASHBACK TABLE command
The PURGE command is used to permanently destroy objectsdropped into the recycle bin Space is not released for droppedobjects until they are purged
New built-in functions are as follows:
COLLECT creates a nested table from the row set result of a gle column in a table (see Chapter 16)
sin- Nested tables have new collection functions (see Chapter 16):
CARDINALITY returns the number of elements in a tion for each row
collec- POWERMULTISET returns all set elements in a collection
POWERMULTISET_BY_CARDINALITY combines theprevious two functions by returning all set elements with aspecified number of entries, for each collection in each row.One could find every row in a table where that collection has
a specified number of entries
SET converts a nested table (collection) for each row to a set
A set contains unique values only such that duplicates areremoved within each collection in each row
SPREADSHEET clause functions are used to facilitate cross culations between different rows Functions include the following(see Chapter 11):
cal- CURRENTV returns a dimensional value or current value
PRESENTNNV returns one expression if a value exists, erwise another
oth- PRESENTV is as for PRESENTNNV except allowing nullvalues
PREVIOUS returns a value at the beginning of each iteration
Trang 2342 2.1 New Features in Oracle Database 10g
NANVL returns a replacement value if the initial value is not
Note: The essential difference between simple pattern matching and regularexpression matching is that simple pattern matching searches for patterns
Regular expression matching searches for patterns allowing for replacementand return of specific values found within a pattern
New statistical aggregation functions are covered in detail inChapter 11 Statistical analysis can be extremely useful in datawarehouse and reporting environments There is now extensivecapability in Oracle SQL for OLAP-type inter-row and cross-rowanalysis, which was previously only available in expensive softwarepackages and add-ons such as Formula1
CORR_{S | K} calculate Pearson’s correlation coefficient,measuring the strength of a linear relationship between twovariables Plotting two variables on a graph results in a lot ofdots plotted from two axes Pearson’s correlation coefficientcan tell you how good the straight line is
MEDIAN returns a median, middle, or interpolated value
Quite literally, a median is the middle sequenced value in aset of values If a distribution is discontinuous and skewed orjust all over the place, the median will not be anywhere near amean or average of a set of values A median is not always ter-ribly useful
Other statistical functions begin with “STATS.” The syntaxappears like this:
STATS_{BINOMIAL_TEST | CROSSTAB | F_TEST | KS_TEST | MODE | MW_TEST | ONE_WAY_ANOVA | STATS_T_TEST_* | STATS_WSR_TEST}
These functions provide various statistical goodies
Chap2.fm Page 42 Thursday, July 29, 2004 9:59 PM
Trang 242.1 New Features in Oracle Database 10g 43
The ORA_HASH function returns a hash value for an expression
New and enhanced operators are as follows:
Collections (nested tables and VARRAY objects) can now be pared using equality (=) and inequality (<> | !=) operators
com- CONNECT_BY_ROOT helps extend hierarchical queries fromparent-child connections only, on to root and below connections(see Chapter 13)
Multiset operators MULTISET {EXCEPT | INTERSECT |UNION} combine results of two collections EXCEPT is similar
to the outer part of an outer join, including all elements in onecollection and not another INTERSECT is the intersection oftwo collections (the unique list of common values) UNIONcombines all elements in both collections (see Chapters 7 and 16)
New pseudocolumns are as follows (see Chapter 7):
Hierarchical pseudocolumns CONNECT_BY_{ISLEAF | CLE} give an indication of contained child elements in a hierar-chy
ISCY- Version query pseudocolumns provide versioning information forflashback version queries
New conditional operators are as follows (see Chapter 7):
Floating-point conditions IS [NOT] {NAN | INFINITE} allowundefined and infinite checks against floating-point numberexpressions
IS [NOT] A SET implies that a collection is a set because it tains unique values only
con- IS ANY qualifies SPREADSHEET clause dimensional values
IS [NOT] EMPTY checks for an empty collection, a nested tablecontaining no elements whatsoever, essentially a collection not asyet instantiated
IS PRESENT ensures that a cell exists before the execution of aSPREADSHEET clause
[NOT] MEMBER OF collection attempts to validate membership
Chap2.fm Page 43 Thursday, July 29, 2004 9:59 PM
Trang 2544 2.1 New Features in Oracle Database 10g
Expressions and the new EVALUATE operator permit what wouldpreviously have been multiple-line SQL statements to be placed into
a single line of SQL or PL/SQL code The term used by Oracle mentation is “describing user’s interest in data” (see Chapter 14)
docu- The Oracle Expression Filter uses an Expression datatype and theEVALUATE operator The EVALUATE operator allows conciseconditional expression evaluation
Portable operating system interface (POSIX) standard regularexpression capabilities allow search-and-replace functionality withchanges to the LIKE operator, REPLACE, and INSTR functions.This search-and-replace capability is equivalent to search-and-replace power in Unix scripting languages or something like theSED editor or when using Perl
2.1.2 PL/SQL Improvements in Oracle Database 10g
An intense examination of the details of PL/SQL is not required in an SQLreference-type book, so some of the items listed here are not covered in thisbook However, a basic introduction to PL/SQL programming is covered inChapter 24
Everything possible in Oracle SQL with respect to SQL coding cannow be coded and executed from within PL/SQL PL/SQL is nowfully syntactically equivalent with Oracle SQL In other words, allOracle SQL commands can be coded into PL/SQL scripts
The PL/SQL compiler is better optimized including bulk bindingand native compilation Native compilation stores PL/SQL units inBLOB objects as a compiled binary form Previously, PL/SQL wasinterpreted PL/SQL code Interpretation implies compilation or con-version to binary at run-time; in the case of PL/SQL, coded com-mands were read and parsed for every execution Binary compilationsimply executes binary code at run-time and is therefore potentiallymuch quicker to execute
Using binary datatypes can help number-crunching performance
Note: Number crunching or heavily computational code should not really
be constructed using a language such as PL/SQL Java or even C is bettersuited, and most commonly at the application level