Oracle8: Database Administration 16-23 . Loading Data Using SQL*Loader The log file is mandatory and the load terminates if the log file cannot be created because of lack of space or permission. The log file contains: • Header information such as the date of the run and software version number • Global information including: - Names of all input and output files - Command line arguments • Table information such as: - Table names - Load conditions and method • Field and column information • Data file information showing records rejected and records discarded with reasons, only for data files with data errors 16-12 Copyright Oracle Corporation, 1998. All rights reserved. Log File Contents • Header information • Global information: parameters and file names • Table information: table and column specifications • Data file information: records processed • Table load information: errors and discards • Summary statistics 16-24 Oracle8: Database Administration . Lesson 16: Loading and Reorganizing Data • Table load information such as: - Number of rows loaded - Number of rows that qualified for loading but were rejected due to data errors - Number of rows that were discarded - Number of rows whose relevant fields were all null • Summary Statistics that displays the following data: - Amount of space allocated for the array - Load statistics for all data files - Beginning/ending time of run - Total elapsed time - Total CPU time including time for all file I/O but excluding any CPU time used by background processes Oracle8: Database Administration 16-25 . Loading Data Using SQL*Loader Bad File The bad file contains records that are rejected during processing due to one of the following reasons: • Input records have errors such as insufficient number or badly formatted fields • Rows could not be inserted for reasons such as constraint violation The records in the bad file are in the same format as the input records. The records can be used, after rectifying the errors, to reload the data. Discard File The discard file contains data in the same format as the input data files and are useful if data needs to be selectively loaded into tables either in different databases or at different points in time. 16-13 Copyright Oracle Corporation, 1998. All rights reserved. SQL*Loader: Other Output Files •Bad file – Rejected records – Same format as data files • Discard file – Records not satisfying conditions – Same format as data files 16-26 Oracle8: Database Administration . Lesson 16: Loading and Reorganizing Data Use the following guidelines when using SQL*Loader to minimize errors and improve performance: • Use a parameter file to specify commonly used command line options. For example, if loading into a data warehouse every week, all options except the names of the files may be the same. • Separating the control file and the data file permits reusing control files for several load sessions. • Preallocating space based on the expected data volume prevents dynamic allocation of extents during the load and improves the speed of the load. • When direct loads are used, temporary segments are used to generate indexes for the new data. These indexes are merged with the existing indexes at the end of the load. By sorting the input data on the keys in the largest index, use of sort space can be minimized. • With Parallel direct loads you can specify the location of temporary segments used for inserting data. For each load session, specify a different database file to achieve maximum performance. Instructor Note For the last bulleted point, you may remind participants that you can specify only files belonging to the tablespace containing the table being loaded. 16-14 Copyright Oracle Corporation, 1998. All rights reserved. SQL*Loader: Usage Guidelines • Use a parameter file to specify commonly used command line options • Place data within the control file only for a small, one-time load • Improve performance by: – Allocating sufficient space – Sorting the data on the largest index – For parallel loads, specify different files for temporary segments Oracle8: Database Administration 16-27 . Loading Data Using SQL*Loader When a load terminates abnormally, all data that has been loaded up to the point of failure is likely to have been committed. After rectifying the problem as discussed in the following paragraphs, proceed as follows to complete the load: • If loading to one table or if all tables have the same number of records processed, use the SKIP command line parameter to continue the load. • If many tables were loaded and the number of records processed is not the same for all tables, use the CONTINUE_LOAD option in the control file to specify the number records to skip for each table. • Check for any indexes marked Unusable. This occurs if the index is not consistent with the table. Drop the indexes in this state and recreate them after completing the load. 16-15 Copyright Oracle Corporation, 1998. All rights reserved. SQL*Loader: Troubleshooting • Insufficient space for table or index • Instance failure during the load • If the SORTED INDEXES clause is used and data is not in the order specified • Duplicate keys found in a unique index, unique or primary key during a direct load • BINDSIZE for conventional load cannot fit one row • Errors or discards exceed specified limit 16-28 Oracle8: Database Administration . Lesson 16: Loading and Reorganizing Data Problem Resolution • Insufficient space: A load may terminate if the Oracle server could not allocate sufficient space to the tables loaded to accommodate all the rows inserted. In this case, investigate the cause of the problem—whether it is due to insufficient disk space, or the files becoming full, or MAXEXTENTS being reached, and correct the problem. • Instance failure: Investigate the reason for failure, rectify it, restart the instance and continue the load. • Data is not in the order specified: The data is loaded, but the index is in an unusable state. Drop and re-create the indexes that are unusable. • Duplicate values in a primary key or unique column or unique index: This does not abort the load process, but may result in disabled constraints or unusable indexes. In the case of constraint errors, use an exceptions table to trap the errors and rectify them. If a unique index is unusable, you may have to detect errors by attempting to create a unique constraint on the indexed column, trapping the errors into an exception table, and correcting them. • BINDSIZE too small: Use a larger value and load the data. • Errors or discards exceeding the limit set: This occurs when a load is aborted because the number of invalid records on discards have exceeded ERRORS or the DISCARDMAX specified. The most common cause of this problem is the use of incorrect input data files. Check and use the correct files. Note The SORTED INDEXES clause is only applicable to direct path loads. For syntax and details of usage refer to the chapter “SQL*Loader Control File Reference” in the manual Oracle8 Server Utilities. Oracle8: Database Administration 16-29 . Reorganizing Data Using Export and Import Reorganizing Data Using Export and Import Export and Import utilities enable the administrator to move data between Oracle databases, and within an Oracle database, to different tablespaces or users, or to reorganize data for efficient storage and performance. Export Utility The Export utility can be used to make a logical copy of object definitions and data to an operating system binary file. Export can write to a file on disk or tape. The Export utility extracts a consistent view of data within each table. Import Utility The Import utility can read the operating system files created by the Export utility and copy the object definitions and data into an Oracle database. Import utility cannot read text files or files created in any other format. Note Views required by the Export and Import utilities are created by running the script catexp.sql, which is invoked when the script catalog.sql is executed. 16-16 Copyright Oracle Corporation, 1998. All rights reserved. Moving Data Using EXP/IMP Data files O/S file Export Import 16-30 Oracle8: Database Administration . Lesson 16: Loading and Reorganizing Data Export and Import can be used in the following cases: • Reorganize tables: There are many instances where tables need reorganization: - Data in one tablespace may need to be moved from one tablespace to another to minimize contention, reduce free-space fragmentation, or to facilitate backup. - A table may contain many migrated rows. - A table may have many blocks that have a very low fill. • Move data owned by one user to another user: This may be necessary when a username needs to be removed from the database or to redistribute object ownership. Data that was exported by one user can be imported into a different user’s account. • Move data between databases: Object definitions can be moved from development to production by extracting only definitions and disregarding data. Export and Import can also be used to extract data from an OLTP application into a data warehouse. 16-17 Copyright Oracle Corporation, 1998. All rights reserved. Uses of Export and Import • Reorganize tables • Move data owned by one user to another user • Move data between databases: – Development to production – OLTP system to a data warehouse • Migrate to a different platform or release of Oracle • Repeat test runs during development or upgrade • Perform a logical backup Oracle8: Database Administration 16-31 . Reorganizing Data Using Export and Import • Migrate to a different platform or release of Oracle: Data that is exported on one machine can be imported into a database on a different machine, possibly using a different character set. When upgrading to a new release of Oracle, data can be exported from the older release and imported into the new release. Note that it may not be possible to use this method for moving data from a later release to an earlier release. • Repeat test runs during development or upgrade: In a development or test database, an application may require several test runs before it is fully debugged and accepted. Test data can be exported to an external file and imported before each run to ensure that tests are performed on the same set of data. This method is also useful to test a new version of Oracle before a production database is upgraded. • Perform logical backup: All or some objects in a database can be exported, and the export file can be used as a logical backup. In this lesson, use of Export and Import for data reorganization and moving data between users is presented. Note Use of Export and Import for backup and recovery is discussed in detail in the course Oracle8: Backup and Recovery Workshop. 16-32 Oracle8: Database Administration . Lesson 16: Loading and Reorganizing Data The Export utility provides three modes of export: • Table • User • Database Table Mode All users can use the table mode to export their own tables. Privileged users can export tables owned by any user. The use of the table mode exports: • The table definition • Data in the table, if required • All indexes on the table if the export is performed by a privileged user (Otherwise, only those indexes on the table owned by the user are exported.) • All triggers on the table only if the utility is run by a privileged user (Otherwise, only the triggers on the table owned by the user are exported.) • Constraints on the table • All grants made on the table • Definition of the analyze method to use on import 16-18 Copyright Oracle Corporation, 1998. All rights reserved. Export Modes Table User Database •Table • Indexes • Triggers •Constraints •Grants •Analyze method • All objects owned by user, except indexes and triggers on tables owned by other users • All objects in the database (except objects owned by SYS) [...]... Lecture Timing 20 minutes Practice 15 minutes Total 35 minutes 17 -2 Oracle8 : Database Administration Objectives Objectives Objectives • Creating new database users • Altering and dropping existing database users • Monitoring information about existing users 17 -2 Copyright © Oracle Corporation, 19 98 All rights reserved Oracle8 : Database Administration. .. utilities to reorganize data 16 - 25 Copyright © Oracle Corporation, 19 98 All rights reserved Quick Reference Context Initialization parameters Dynamic performance views Data dictionary views Commands: UNIX Reference None None None sqlldr or sqlload exp imp Windows NT EXP80.EXE IMP80.EXE SQLLDR80.EXE Packaged procedures and functions None 16- 48 Oracle8 : Database Administration 17 Managing... imported into a database running Oracle7 , release 7.3.3 or higher Oracle8 : Database Administration 16- 45 Lesson 16: Loading and Reorganizing Data NLS Considerations in Export and Import Export Database character set Export client character set Import Import client character set Possible character set conversion 16 -24 Copyright © Oracle Corporation, 19 98 All rights... 16- 42 Oracle8 : Database Administration Reorganizing Data Using Export and Import Import Behavior • Order of Import – Table Data B-tree Indexes Constraints, Triggers, Bitmap indexes • Tablespace used for the object – Same tablespace as in the source database, if possible – User’s default tablespace 16 -22 Copyright © Oracle Corporation, 19 98 All rights reserved Order... reference, see the chapter “Export” in the manual Oracle8 Server Utilities 16- 38 Oracle8 : Database Administration Reorganizing Data Using Export and Import Using Import $imp scott/tiger tables=(dept,emp) \ > file=emp.dmp log=imp.log ignore=y imp.log emp.dmp Import Copyright © Oracle Corporation, 19 98 All rights reserved 16 -21 Import can be invoked using: • Command line... the time the user is defined in the database and can be altered later This lesson covers authentication by database and by operating system only Note • Refer to O/S Authentication using roles in the lesson “Managing an Oracle Instance.” • Authentication through the network is covered in the course Oracle8 : Network Administration 17-4 Oracle8 : Database Administration Overview ... the export path used 16-34 Oracle8 : Database Administration Reorganizing Data Using Export and Import Using Export $exp scott/tiger tables=(dept,emp) \ > file=emp.dmp log=exp.log compress=n \ > direct=y recordlength= 327 68 emp.dmp Export DEPT,EMP tables exp.log Copyright © Oracle Corporation, 19 98 All rights reserved 16 -20 Export can be invoked using: • Command line... system, and manually controlling account locking Oracle8 : Database Administration 17 -5 Lesson 17: Managing Users Database Schema Tables - Triggers - Constraints Indexes Views Sequences Stored program units Synonyms User-defined data types Database links 17-4 Copyright © Oracle Corporation, 19 98 All rights reserved Schema A schema is a named collection of objects... New Database Users Checklist for Creating Users 1 Choose a username and authentication mechanism 2 Identify tablespaces in which the user needs to store objects 3 Decide on quotas for each tablespace 4 Assign default tablespace and temporary tablespace 5 Create a user 6 Grant privileges and roles to the user 17 -5 Copyright © Oracle Corporation, 19 98 All rights reserved Oracle8 : Database. .. particular user When a database user is created, a corresponding schema with the same name is created for that user A user can only be associated with a schema of the same name, and therefore username and schema are often used interchangeably The slide shows some of the objects that users can own in an Oracle database 17-6 Oracle8 : Database Administration Creating New Database Users . exceed specified limit 16- 28 Oracle8 : Database Administration . Lesson 16: Loading and Reorganizing Data Problem Resolution • Insufficient space: A load may terminate if the Oracle server could. to the chapter “SQL*Loader Control File Reference” in the manual Oracle8 Server Utilities. Oracle8 : Database Administration 16 -29 . Reorganizing Data Using Export and Import Reorganizing Data. Import for backup and recovery is discussed in detail in the course Oracle8 : Backup and Recovery Workshop. 16- 32 Oracle8 : Database Administration . Lesson 16: Loading and Reorganizing Data The