Oracle Unleashed- P6

50 311 0
Oracle Unleashed- P6

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Enter table name or . if done: dept Enter table name or . if done: . The last example is from full database mode. Import entire export file (yes/no): yes >Y User Mode The user method of Import enables you to import tables that belong to a specific user. This can also be combined with the table mode to import specific tables from a specific schema. This is important because Import attempts to create the tables in the current schema's default tablespace if the schema specified in the export file does not exist. This can work to your advantage if you need to move tables from one schema to another. Table Mode You usually use table mode to import a table or a list of tables, rather than all tables in the export file. If a user has access to other schema, he can import tables from other schema by qualifying with the schema name. The default is to import all tables in the schema of the user doing the import. Full Database Mode The full database option of Import does not quite work the same way as the full database option of Export. If you specify the full database option in Export, the entire database is exported, and to import the entire file, you must have the role IMP_FULL_DATABASE assigned to you. If the export file is a user export or table export, the entire export file is imported (whatever is in it), and you do not need to have the role IMP_FULL_DATABASE assigned to you. Interactive Versus Command Line Both Import and Export can operate in command-line mode and in interactive mode. Both modes have their advantages, but Oracle recommends that you use the command-line mode with a parameter file. The two modes are outlined in this section. I'm sure you will find good reasons for using both in your own situation. Interactive Method The interactive method is an easy way to import data from export files, but you do not have all the options of the parameter or command-line method. For example, you cannot create an index file. The interactive prompts might change depending on the response to previous prompts. The interactive prompts also have the benefit of showing the prechosen defaults. To use Import in the interactive mode, type imp or imp USERID=userid/password at the command line. The interactive method continues to exist only for backward compatibility. An interactive import might resemble the following: /usr/local/p3016dk > imp scott/tiger Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Import: Release 7.1.4.1.0 - Production on Sun Oct 1 10:12:54 1995 Copyright (c) Oracle Corporation 1979, 1994. All rights reserved. Connected to: Oracle7 Server Release 7.1.4.1.0 - Production Release With the distributed and parallel query options PL/SQL Release 2.1.4.0.0 - Production Import file: ./expdat.dmp > scott.dmp Enter insert buffer size (minimum is 4096) 30720> Export file created by EXPORT:V07.01.04 List contents of import file only (yes/no): no > Ignore create error due to object existence (yes/no): yes > n Import grants (yes/no): yes > y Import table data (yes/no): yes > y Import entire export file (yes/no): yes > y Command-Line Method The same import can be accomplished by entering the following command-line options. imp USERID=scott/tiger FILE=scott.dmp ignore=N Import responds with the following: Import: Release 7.1.4.1.0 - Production on Sun Oct 1 10:19:12 1995 Copyright (c) Oracle Corporation 1979, 1994. All rights reserved. Connected to: Oracle7 Server Release 7.1.4.1.0 - Production Release With the distributed and parallel query options PL/SQL Release 2.1.4.0.0 - Production Export file created by EXPORT:V07.01.04 . importing SCOTT's objects into SCOTT . . importing table "BONUS" 0 rows imported . . importing table "CUSTOMER" 9 rows imported . . importing table "DEPT" 4 rows imported . . importing table "DUMMY" 1 rows imported Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. . . importing table "EMP" 14 rows imported . . importing table "EXECUTABLES" 0 rows imported . . importing table "FALL5" 30 rows imported . . importing table "ITEM" 64 rows imported . . importing table "ORD" 21 rows imported . . importing table "PRICE" 17 rows imported Import terminated successfully without warnings. Import Parameters That Affect Performance As with Export, Import also has several parameters that affect performance. This section lists the parameters that affect performance the most along with an explanation of how they work and how to use them. BUFFER The BUFFER parameter for Import works the same way as the BUFFER parameter in Export. For the most part, you can specify a large value for best results. COMMIT The COMMIT parameter defaults to N, but if do not have large rollback segments to use (at least as large as the largest table), set this option to Y. If you set COMMIT to Y, Import commits every time the buffer fills and the array is inserted. The only significant performance gain you will notice is when your import fails because of a rollback issue and you must redo an import. LOG Quite simply, always use the LOG parameter so you can review the log file and effectively fix anything that went wrong. How Objects Import Objects are created in a specific order as the import progresses. The important thing to remember is that Import first creates the table and then loads the data for each table. Import creates all the indexes on the tables after it loads all the table data. Finally, Import enables all the table constraints and triggers. In some situations, the table constraints can cause interesting results (usually undesirable). If you are in the habit of precreating the tables before the import as I am, you know you'd better disable the constraints before importing. Reenable the constraints when the import is finished. Don't forget! Tables Import first creates the table definitions and then loads the data. Import creates all the indexes for the table and then creates and enables the constraints and database triggers. The important thing to note is that all the tables are loaded and all of the indexes are created a table at a time. When the tables are finished, Import creates and reenables all the table constraints. Stored Procedures Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Packages, functions, and stored procedures are imported without updating the time stamp. This enables Oracle to use the objects without recompiling them. Snapshots Snapshots are exported quite uneventfully. Oracle exports and imports the master table, the master table trigger, the snapshot log (if you are using one), and the snapshot itself, similar to exporting and importing tables and database triggers. If you are using a snapshot log, only the snapshot log definition is exported and imported. What this means to you is that the first fast refresh that is attempted on that snapshot will fail. Plan on a complete refresh of all of the imported snapshots after the import is complete. Importing and Exporting with Personal Oracle7 My world has not been the same since Oracle introduced Personal Oracle7. I have been able to develop complete applications on my PC at home. Although I do not have a PC platform that compares with our Sequent, HP, or DG platforms, I can't resist the desire to develop applications on it. I haven't yet used Personal Oracle7 for any production applications, but I am sure many people have. All of us who have had the pleasure of experiencing Personal Oracle7 will agree that the Windows front end on the Import and Export utilities is a nice addition to the old familiar utilities. I think that many Personal Oracle7 users like me are developing applications. I find myself exporting tables from the true development platforms at the job site and then importing them into my PC database so I can develop whenever and whatever I like. Using the Personal Oracle7 version of Import and Export is quite a bit different from the old standards. Personal Oracle7 has a nice GUI interface that is hard to beat. It still works internally the same way as the character versions and outputs files that you can transfer to other Oracle instances. The main difference in Personal Oracle7 is the Windows front end. Figure 9.1 shows the Export utility in Personal Oracle7; the title bar has the caption Database Exporter. The first thing you notice is that parameters are represented by text boxes, checkboxes, or pull-down lists. Figure 9.2 shows the advanced options. The advanced options are Record Length (RECORDLENGTH), Buffer Size (BUFFER), Record Export in System Data (RECORD), Keep Components Consistent (CONSISTENT), Compress When Imported (COMPRESS), Log File (LOG) Increment Type (INCTYPE), and Statistics Type (STATISTICS). The other Export parameters follow similar translations. Figure 9.1. Personal Oracle's Export utility. Figure 9.2. Export utility advanced options. Figure 9.3 and 9.4 show the Database Importer and the advanced options available. The Database Importer closely resembles the Exporter's look and feel. I do not go into detail because its functionality is fairly obvious. Figure 9.3. The Import utility. Figure 9.4. Import utility advanced options. Import and Export Hints and Tips You can use Import and Export for tasks other than just backing up data. I often use Import and Export for several other constructive reasons, and this section outlines a few of the best hints and tips. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Create an Index File Import can create what is known as an index file. This is a SQL script of not only the creation scripts for the indexes in the export file but also creation scripts for the other database objects in the export file. All the lines in the file except for the index creation scripts are commented out. The commented-out code contains creation scripts for the remaining objects in the export file. With some editing, you can create a script that can be used to precreate all the tables and indexes and so on. This is often necessary if you use the parameter COMPRESS=Y. Adjusting Storage Parameters Using the parameter COMPRESS=Y rewrites the original storage parameters so that the table or index resides on one contiguous extent. Compressing the extents is a good idea as long as you actually have the contiguous extents available. I suggest precreating the tables and indexes with your edited INDEXFILE. This ensures that you can actually create the objects. Of course, if any table or index fails to create, you can adjust the initial and next extents in the INDEXFILE and attempt to create the table again. This is also a good time to adjust the PCTFREE and PCTUSED and the TABLESPACE parameters (or any of the other table parameters) in the table and index creation statements. I highly recommend that you study and adjust the size requirement if necessary at this time, especially if the storage parameters are set to their defaults. I don't go into great detail, but here are some good places to start if you have a mess of default storage parameters: Parameter Defaults to Set to PCTFREE 10% 5-20% PCTUSED 40% 55-90% PCTINCREASE 50% 0% INITIAL 10240 or 2048 All data in one extent plus some growth if possible NEXT 10240 or 20480 25% up to the size of INITIAL There are other storage parameters, but these five are typically the most important to me. Reorganizing Data Users own tables, indexes, and other objects. The tables and indexes users create reside in tablespaces. If you were to export a user's tables, drop them, and then import them, they end up in the user's default tablespace again. If you need to move tables from one tablespace to another, you export the tables and change the user's default tablespace and quotas to another tablespace that you want to contain the tables. Then, when you reimport the tables, they are created in the new default tablespace. Reducing Database Fragmentation When a database has many small blocks of free space, you should export it with the FULL=Y parameter. Recreate the database and then do a full database import. Tablespaces also need similar help. You should plan carefully where and how many data files a tablespace has. To recreate the tablespace, export all the objects, using the nifty script I provided if Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. you like. Drop the tablespace including its contents. Recreate the tablespace and then import the fresh new tablespace. Migrating from Version 6 to Oracle7 Import can read export files from Version 6 Oracle. You could use this function to migrate by exporting the Version 6 database and then recreating the database in Oracle7. Some data type changes occurred after Version 6; the old Version 6 CHAR data type changed to VARCHAR2. Import handles this conversion for you. If you're wondering who is going to change all your table creation scripts from the old CHAR data type to VARCHAR2, try using the INDEXFILE parameter explained earlier. Oracle7 provides vastly expanded integrity constraints, and the SQL syntax is slightly different from Version 6. All the existing constraints are exported, but only the NOT NULL constraint is imported and enabled. Importing Tables with LONG and LONG RAW Data Types Did you know it is possible to export a table with extremely large columns (LONG data types can be up to 2 GB in length) only to discover that they cannot be imported? It hasn't happened to me, but Oracle reports that this could happen. The reason is that Export can break up the long data, but Import must read the data into contiguous memory to import. If you do not have enough memory, the import fails. Summary Import and Export not only provide data recovery, but they have quite a few database management uses as well. I am sure you will find yourself using Import and Export often to keep your database tuned well by reducing fragmentation and enabling yourself to change the storage parameters of tables and their locations or owners. Whatever task you choose for Import and Export, you will find them to be a stable pair of utilities that are easy to use. Previous Page TOC Next Page Home Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Previous Page TOC Next Page Home ● Part III Part III Database Administration Previous Page TOC Next Page Home Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Previous Page TOC Next Page Home ● 10 ❍ Installation ■ Oracle Software Options ■ Base Product ■ Procedural Option ■ Distributed Option ■ Parallel Server Option ■ Parallel Query Option ■ Trusted Oracle ■ Installation Preparation ■ Installing the Software ■ Directory Structure ■ Operating System Specifics ■ UNIX ■ VMS ■ MS Windows ■ Summary 10 Installation In this chapter we look at some of the issues involved in installing the Oracle software and database. However, since Oracle runs on over 90 different platforms, we can only give an overview of the process involved here—the specifics for your operating system can be found in the Oracle Installation and User's Guide manual which comes with the software. In addition, the last-minute System Release Bulletin that comes with the software should be studied, along with the even later produced README.DOC file that is on the install media. On most platforms, if a user process connects directly to the database server machine, two things must be known. One is the starting location of the Oracle software directory, and the other is the instance identifier to which the user process will connect to. This information is provided in different ways on different operating systems, but many use an operating system command file named something such as "orauser" or "oraenv" to set up these operating system variables as soon as a user logs into the machine. During the installation process, on most machines, an option is given to install a default database by choosing some menu options. Chapter 11, "Managing the Database," covers how to create a database if you either don't want to or can not use the menus to give you this starting database. Usually the menus are sufficient to create a practice database, but for production and real systems, more control is needed over the choices available when creating a new database. Installation of the Oracle tools is usually done at the same time as installation of the Oracle software. For client/server environments, an added complication is that the tools exist on a different machine than that on which the database software resides. To allow the two machines to communicate between each other, some networking software must be installed on both machines (such as TCP/IP), and on top of that both machines need a flavor of SQL*Net installed so that the Oracle software can interface to the networking software. Installing SQL*Net software for the network protocol you're using is usually done at the same time as installing the Oracle server software and tools software. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. This is one of the areas where there are major differences between different operating systems due to the nature of the process itself. Oracle Software Options When you purchase the Oracle software, a number of additional software options are available. However, these options may not be available on all platforms at the same time (for example, at the time of this writing, the Distributed option was not yet available on the Personal Oracle 7 version of the software). Base Product The standard product (without the addition of the procedural, distributed, parallel, or other options) gives you the SQL language—without this not much can be done on the database. In the near future, the PL/SQL language is also to be included in the standard, base product. In addition, the database only locks those rows which are actually being modified instead of locking out the entire table. (This was an option that had to be purchased separately in version 6 of the database server.) The base product also includes the capability to do parallel recoveries in the case of media failure, which means that you can have more than one process running the recover tablespace command. All of these processes can run in parallel and will use whichever archived and online redo log files are required for the tablespace being recovered. Parallel tablespace backup commands can also be issued, as well as parallel loads of data from operating system files using the SQL*Loader product with the direct load path option, which is available with that product. Procedural Option The procedural option gives the you ability to use PL/SQL and to create procedures, functions, packages, and database triggers. At the time of this writing, this was being bundled in as part of the base product, and so was not an additional option for most platforms. Distributed Option The base product itself gives you the ability to write distributed queries—queries which in the same transaction or even in the same statement, query tables on one or more databases, usually by using database links (which have already been defined by the database administrator). In addition, the user can connect to a remote database and make changes to tables on that database. However, one thing that is not possible without the distributed option is the capability to make changes to tables on more than one database within the same transaction (the same commit unit). The distributed option allows one transaction to make changes to more than one database. When the changes are committed (or rolled back), the Oracle server software ensures that either all the databases commit, or if anything goes wrong, that they all rollback the work. This is provided without requiring the developer to put in any more code than the normal commit or rollback statement. The synchronization mechanism is provided using the 2-Phase Commit algorithm, which synchronizes all the databases involved. In addition, with the distributed option, one non-Oracle database can take part in a distributed transaction. Usually this involves using the Oracle Gateway products which allow access to non-Oracle data sources. If any failures do occur with a distributed transaction, the Oracle RECO background process periodically tries to either commit or to rollback the changes on the databases involved. It is better for the database administrator to allow the RECO process to recover the distributed transaction without getting involved. The Oracle data dictionary tables, DBA_2PC_NEIGHBORS and DBA_2PC_PENDING, give further information on the transactions which have been Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. involved in a distributed failure. The distributed option is also required if you wish to create Snapshots which are copies of tables (usually) on other databases which are automatically replicated to your database at user defined intervals. In addition, the distributed option includes the capability to call procedures, functions, and packages, which have been defined on remote databases. So, in theory though not very practically, you can hold the database procedures, functions, and packages on one central database, and all other databases can make calls to this central copy of the code. Parallel Server Option The Oracle parallel server option allows more than one instance to access the same set of database files. This option ensures, for example, that if a row is locked on one instance that it is reported as locked on any other instances accessing the same database. The parallel server option is be used where more than one processor is available (either in the same machine or in different machines which have been clustered together). Parallel Query Option The parallel query option improves performance of full-table scans. This allows a large query to be executed by multiple processes so that many processes can be used to perform parts of the query, with the results being merged together automatically. In addition, the parallel query option allows creation of indexes in parallel. This is similar in concept to the parallel query mentioned earlier, where more than one process can be used to build different parts of the index, and the results from each of these processes is merged together. The parallel query option normally runs on those machines where more than one processor has been installed so that you can use the processing power of more than one processor to perform the heavy-load work which you require. Trusted Oracle Trusted Oracle provides additional security than what is available with the base product and is usually found either in military type applications or those where a high level of security is required. This gives, for example, the ability to control which rows are accessible to which users. This is not easily done with the base product. Tip: Use the v$version view, which is accessible to the system user, to see which versions of the Oracle product you have installed. In addition, the v$compatseg view shows which version of the Oracle server software introduced some of the new releases. Installation Preparation The actual process of installing the Oracle software and creating the first database is relatively easy on most platforms because you can follow the menu options; however, preparation before the actual install pays dividends in the long run. One of the first things to consider is the amount of disk space required both for the software and for the database itself. In addition, the locations of the program files, database files, redo logs, and control files should be carefully considered so that disk contention does not occur. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... for the Oracle software, and the $ORACLE_ SID environment variable is used to determine which instance ID the user process will connect into The PATH environment variable should include the $ORACLE_ HOME/bin directory so that you can access the various Oracle components One of the options available for the UNIX platform is to allow Oracle to use raw disk devices—essentially this means that the Oracle. .. where the starting location is for the Oracle software ( $ORACLE_ HOME for UNIX, ORA_ROOT for VMS and the ORACLE. INI file for the MS Windows platform) Once this environment variable exists, Oracle can work out the locations of the subdirectories and gain access to the files it requires It is also possible on some platforms to install many different versions of the Oracle software Operating System Specifics... To access the parameters from any Oracle tool, run a select operation against the v$parameter table, as in Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark SQLPLUS> SELECT * FROM v$parameter You must have access to the v$parameter table, which is owned by the Oracle user SYS The Oracle SID The Oracle System Identifier (SID) identifies the Oracle instance on the machine It... database from one stage of startup to another Refer to the Oracle SQL Language Reference Guide for more information on this command The Data Dictionary The Oracle data dictionary is a set of tables that the Oracle software uses to record information about the structure of the database These core system tables are owned by the Oracle user present on all Oracle databases—the SYS user SYS is rarely used, even... objects owned by the Oracle user running the query Suppose, for example, that a table called FOOTBALL is owned by the Oracle user LINEKER and a table called BOXING is owned by the Oracle user BRUNO If you log into the Oracle account LINEKER and query the USER_TABLES view, the only table that you will see is the FOOTBALL table If you disconnect from that user and connect to the Oracle user BRUNO and... sites new to UNIX and new to Oracle VMS The ORA_ROOT logical is used to point to the location of the home directory for the Oracle software In addition, the ORA_SID symbol is used to determine the instance identifier of the instance to which user processes will connect MS Windows This is nowadays one of the easiest platforms on which to install the Oracle tools and software The ORACLE. INI file is used to... structure exists, the Oracle default home directory has a name such as "Oracle7 ," and below this you'll find many subdirectories—usually one for each product being installed Within each of these product subdirectories, further subdirectories exist for things such as the install scripts, demo files, and so on The directory structure underneath the Oracle home directory should not be changed Oracle needs to... you learn how to perform the following tasks: q Make a new Oracle database q Manage the instance by bringing the instance up and down q Obtain information from the Oracle system tables q Modify the number of control and redo log files The Parameter File: INIT.ORA An instance is the set of background processes and the memory structures that Oracle uses Every instance must have a parameter file, known... exactly as it appears on the file system You specify over 130 parameters Most of them are common to all the platforms on which Oracle runs The number of the parameters increase from one release of the Oracle RDBMS software to the next An example parameter file comes with the Oracle software; its default name is INIT.ORA You can use this file could to run your instance, although you might have to adjust... a minimum value If they are set below the minimum value, the Oracle instance does not start up The values of some parameters are derived from settings in other parameters Normally, you do not need to set them There are even some parameters that you should not set unless the Oracle support desk instructs you to set them Appendix A of the Oracle7 Server Administrator's Guide describes all the different . Oracle software ( $ORACLE_ HOME for UNIX, ORA_ROOT for VMS and the ORACLE. INI file for the MS Windows platform). Once this environment variable exists, Oracle. v$parameter table, which is owned by the Oracle user SYS. The Oracle SID The Oracle System Identifier (SID) identifies the Oracle instance on the machine. It

Ngày đăng: 17/10/2013, 23:15

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan