managing data

20
9 Copyright © 2004, Oracle. All rights reserved. Managing Data

Upload: brady-logan

Post on 03-Jan-2016

69 views

Category:

Documents


1 download

DESCRIPTION

Managing Data. Objectives. After completing this lesson, you should be able to do the following: Manipulate data through SQL Use Data Pump to export data Use Data Pump to import data Load data with SQL Loader. Manipulating Data Through SQL. SQL> INSERT INTO employees VALUES - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Managing Data

9Copyright © 2004, Oracle. All rights reserved.

Managing Data

Page 2: Managing Data

9-2 Copyright © 2004, Oracle. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:

• Manipulate data through SQL

• Use Data Pump to export data

• Use Data Pump to import data

• Load data with SQL Loader

Page 3: Managing Data

9-3 Copyright © 2004, Oracle. All rights reserved.

Manipulating Data Through SQL

SQL> INSERT INTO employees VALUES 2 (9999,'Bob','Builder','[email protected]',NULL,SYSDATE, 3 'IT_PROG',NULL,NULL,100,90);

1 row created.

SQL> UPDATE employees SET SALARY=6000 2 WHERE EMPLOYEE_ID = 9999;

1 row updated.

SQL> DELETE from employees 2 WHERE EMPLOYEE_ID = 9999;

1 row deleted.

Page 4: Managing Data

9-4 Copyright © 2004, Oracle. All rights reserved.

The INSERT Command

• Create one row at a time.

• Insert many rows from another table.

Page 5: Managing Data

9-5 Copyright © 2004, Oracle. All rights reserved.

The UPDATE Command

Use to change zero or more rows of a table.

Page 6: Managing Data

9-6 Copyright © 2004, Oracle. All rights reserved.

The DELETE Command

Use to remove zero or more rows from a table.

Page 7: Managing Data

9-7 Copyright © 2004, Oracle. All rights reserved.

The COMMIT and ROLLBACK Commands

Used to finish a transaction.

• Commit: Makes the change permanent

• Rollback: Undoes the change

Page 8: Managing Data

9-8 Copyright © 2004, Oracle. All rights reserved.

Integrity Constraints and DML

Page 9: Managing Data

9-9 Copyright © 2004, Oracle. All rights reserved.

Data Pump Export

Page 10: Managing Data

9-11 Copyright © 2004, Oracle. All rights reserved.

Data Pump Import

Page 11: Managing Data

9-13 Copyright © 2004, Oracle. All rights reserved.

DIRECTORY Objects

SQL> CREATE DIRECTORY dpump_dir1 2 AS '/usr/apps/datafiles';

Directory created.

SQL> SELECT * FROM DBA_DIRECTORIES 2 WHERE DIRECTORY_NAME = 'DPUMP_DIR1';

OWNER DIRECTORY_NAME DIRECTORY_PATH------- --------------- --------------------SYS DPUMP_DIR1 /usr/apps/datafiles

Page 12: Managing Data

9-14 Copyright © 2004, Oracle. All rights reserved.

SQL*Loader

Input

data files

Control

File

SQL*LoaderLog

fileBad

files

Discard

files

Tables and indexes

Page 13: Managing Data

9-16 Copyright © 2004, Oracle. All rights reserved.

The SQL*Loader Control File

The loader control file tells SQL*Loader:

• Where to find the load data

• The data format

• Configuration details:– Memory management– Record rejection– Interrupted load handling details

• How to manipulate the data

Page 14: Managing Data

9-19 Copyright © 2004, Oracle. All rights reserved.

Control File Syntax Considerations

• The syntax is free-format.

• Syntax is not case sensitive.

• Comments extend from the two hyphens (--) that mark the beginning of the comment to the end of the line.

• The CONSTANT keyword is reserved.

Page 15: Managing Data

9-20 Copyright © 2004, Oracle. All rights reserved.

Input Data and Data Files

• SQL*Loader reads data from one or more files specified in the control file.

• From SQL*Loader’s perspective, the data in the data file is organized as records.

• A data file can be in one of three formats:– Fixed-record format– Variable-record format– Stream-record format

Page 16: Managing Data

9-23 Copyright © 2004, Oracle. All rights reserved.

Loading Methods

ConventionalDirectpath

Arrayinsert

Block writes

Table

SGA

High-water mark

Page 17: Managing Data

9-25 Copyright © 2004, Oracle. All rights reserved.

Comparing Direct and Conventional Path Loads

Conventional Load

Uses COMMIT to makechanges permanent

Redo entries alwaysgenerated

Enforces all constraints

INSERT triggers fire

Can load into clusteredtables

Other users can make changes to tables

Direct Path Load

Uses data saves

Generates redo only underspecific conditions

Enforces only PRIMARY KEY, UNIQUE, and NOT NULL

INSERT triggers do not fire

Cannot load intoclustered tables

Other users cannotmake changes to tables

Page 18: Managing Data

9-27 Copyright © 2004, Oracle. All rights reserved.

Loading Data with SQL*Loader

Page 19: Managing Data

9-29 Copyright © 2004, Oracle. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Manipulate data through SQL

• Use Data Pump to export data

• Use Data Pump to import data

• Load data with SQL Loader

Page 20: Managing Data

9-30 Copyright © 2004, Oracle. All rights reserved.

Practice 9: Using Data Pump Export and Import

This practice covers the following:

• Creating a directory object

• Extracting the HR schema objects

• Using Data Pump import to load tables into a different schema