Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

rekharaghuram
from rekharaghuram More from this publisher
05.11.2015 Views

CHAPTER 3 ■ FILES 113 tkyte@ORA10G> select * 2 from nls_database_parameters 3 where parameter = 'NLS_CHARACTERSET'; PARAMETER VALUE ------------------------------ ----------------- NLS_CHARACTERSET WE8MSWIN1252 Oracle has the ability now to recognize the differing character sets due to the Data Pump file format and deal with them. Character-set conversion can be performed on the fly as needed to make the data “correct” in each database’s representation. Again, we’ll come back to the Data Pump file format in Chapter 15, but this section should give you an overall feel for what it is about and what might be contained in the file. Flat Files Flat files have been around since the dawn of electronic data processing. We see them literally every day. The alert log described previously is a flat file. I found these definitions for “flat file” on the Web and feel they pretty much wrap it up: An electronic record that is stripped of all specific application (program) formats. This allows the data elements to be migrated into other applications for manipulation. This mode of stripping electronic data prevents data loss due to hardware and proprietary software obsolescence. 1 A computer file where all the information is run together in a signal character string. 2 A flat file is simply a file whereby each “line” is a “record,” and each line has some text delimited, typically by a comma or pipe (vertical bar). Flat files are easily read by Oracle using either the legacy data-loading tool SQLLDR or external tables—in fact, I will cover this in detail in Chapter 15 (external tables are also covered in Chapter 10). Flat files, however, are not something produced so easily by Oracle—for whatever reason, there is no simple commandline tool to export information in a flat file. Tools such as HTMLDB and Enterprise Manager facilitate this process, but there are no official command-line tools that are easily usable in scripts and such to perform this operation. That is one reason I decided to mention flat files in this chapter: to propose a set of tools that is capable of producing simple flat files. Over the years, I have developed three methods to accomplish this task, each appropriate in its own right. The first uses PL/SQL and UTL_FILE with dynamic SQL to accomplish the job. With small volumes of data (hundreds or thousands of rows), this tool is sufficiently flexible and fast enough to get the job done. However, it must 1. See http://osulibrary.oregonstate.edu/archives/handbook/definitions. 2. See http://www.oregoninnovation.org/pressroom/glossary.d-f.html.

114 CHAPTER 3 ■ FILES create its files on the database server machine, which is sometimes not the location we’d like for them. To that end, I have a SQL*Plus utility that creates flat files on the machine that is running SQL*Plus. Since SQL*Plus can connect to an Oracle server anywhere on the network, this gives us the ability to unload to a flat file any data from any database on the network. Lastly, when the need for total speed is there, nothing but C will do (if you ask me). To that end, I also have a Pro*C command-line unloading tool to generate flat files. All of these tools are freely available at http://asktom.oracle.com/~tkyte/flat/index.html, and any new tools developed for unloading to flat files will appear there as well. Summary In this chapter, we explored the important types of files used by the Oracle database, from lowly parameter files (without which you won’t even be able to get started) to the all important redo log and data files. We examined the storage structures of Oracle from tablespaces to segments, and then extents, and finally down to database blocks, the smallest unit of storage. We reviewed how checkpointing works in the database, and we even started to look ahead at what some of the physical processes or threads of Oracle do.

114<br />

CHAPTER 3 ■ FILES<br />

create its files on the database server machine, which is sometimes not the location we’d like<br />

for them. To that end, I have a SQL*Plus utility that creates flat files on the machine that is<br />

running SQL*Plus. Since SQL*Plus can connect to an <strong>Oracle</strong> server anywhere on the network,<br />

this gives us the ability to unload to a flat file any data from any database on the network.<br />

Lastly, when the need for total speed is there, nothing but C will do (if you ask me). To that<br />

end, I also have a Pro*C comm<strong>and</strong>-line unloading tool to generate flat files. All of these tools<br />

are freely available at http://asktom.oracle.com/~tkyte/flat/index.html, <strong>and</strong> any new tools<br />

developed for unloading to flat files will appear there as well.<br />

Summary<br />

In this chapter, we explored the important types of files used by the <strong>Oracle</strong> database, from<br />

lowly parameter files (without which you won’t even be able to get started) to the all important<br />

redo log <strong>and</strong> data files. We examined the storage structures of <strong>Oracle</strong> from tablespaces to segments,<br />

<strong>and</strong> then extents, <strong>and</strong> finally down to database blocks, the smallest unit of storage. We<br />

reviewed how checkpointing works in the database, <strong>and</strong> we even started to look ahead at what<br />

some of the physical processes or threads of <strong>Oracle</strong> do.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!