1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Managing Tables pptx

23 167 0
Tài liệu đã được kiểm tra trùng lặp

Đ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

Thông tin cơ bản

Tiêu đề Managing Tables
Trường học Oracle University
Chuyên ngành Database Management
Thể loại Bài giảng
Năm xuất bản 2002
Thành phố Redwood Shores
Định dạng
Số trang 23
Dung lượng 537,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Storing User DataRegular table Cluster Partitioned table Index-organized table... Creating a TableCREATE TABLE hr.employees employee_id NUMBER6, first_name VARCHAR220, last_name VARCHAR2

Trang 1

11Managing Tables

Trang 2

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

Identify the various methods of storing data

Outline Oracle data types

Distinguish between an extended versus a restricted

ROWID

Outline the structure of a row

Create regular and temporary tables

Manage storage structures within a table

Reorganize, truncate, and drop a table

Drop a column within a table

Trang 3

Storing User Data

Regular table

Cluster

Partitioned table

Index-organized

table

Trang 4

Oracle Built-in Data Types

REF

Data type

Built-in User-defined

Trang 5

ROWID Format

Extended ROWID Format

Restricted ROWID Format

Data object

number

Relative file number

Row number Block number

Trang 6

Structure of a Row

Database block

Row header Column length Column value

Trang 7

Creating a Table

CREATE TABLE hr.employees(

employee_id NUMBER(6), first_name VARCHAR2(20), last_name VARCHAR2(25), email VARCHAR2(25),

phone_number VARCHAR2(20), hire_date DATE DEFAULT SYSDATE, job_id VARCHAR2(10),

salary NUMBER(8,2), commission_pct NUMBER (2,2), manager_id NUMBER(6),

department_id NUMBER(4)) TABLESPACE USERS;

Trang 8

Creating a Table: Guidelines

Place tables in separate tablespaces.

Use locally-managed tablespaces to avoid

fragmentation.

Use few standard extent sizes for tables to reduce

tablespace fragmentation.

Trang 9

Creating Temporary Tables

Created using the GLOBAL TEMPORARY clause:

Tables retain data only for the duration of a

transaction or session.

DML locks are not acquired on the data.

You can create indexes, views, and triggers on

Trang 10

(Average Row Size - Initial Row Size) * 100

Average Row Size

Average Row Size * 100

100 - PCTFREE - -

-Available Data Space

Setting PCTFREE and PCTUSED

Compute PCTFREE

Compute PCTUSED

Trang 11

Before update After update

Pointer

Row Migration and Chaining

Trang 12

Changing Storage and Block

Trang 13

Manually Allocating Extents

ALTER TABLE hr.employees

ALLOCATE EXTENT(SIZE 500K

DATAFILE ‘/DISK3/DATA01.DBF’);

Trang 14

Nonpartitioned Table Reorganization

When a nonpartitioned table is reorganized, its

structure is kept, but not its contents.

It is used to move a table to a different tablespace or

reorganize extents.

ALTER TABLE hr.employees

MOVE TABLESPACE data1;

Trang 15

Truncating a Table

Truncating a table deletes all rows in a table and

releases used space.

Corresponding indexes are truncated.

TRUNCATE TABLE hr.employees;

Trang 16

Dropping a Table

DROP TABLE hr.departments

CASCADE CONSTRAINTS;

Trang 17

Dropping a Column

Removing a column from a table:

Removes the column length and data from each row,

freeing space in the data block.

Dropping a column in a large table takes a

considerable amount of time.

ALTER TABLE hr.employees

DROP COLUMN comments

CASCADE CONSTRAINTS CHECKPOINT 1000;

Trang 18

Renaming a Column

Renaming a column from a table:

ALTER TABLE hr.employees

RENAME COLUMN hire_date

TO start_date;

Trang 19

Using the UNUSED Option

Mark a column as unused:

Drop unused columns:

Continue to drop column operation:

ALTER TABLE hr.employees

SET UNUSED COLUMN comments CASCADE

CONSTRAINTS;

ALTER TABLE hr.employees

DROP UNUSED COLUMNS CHECKPOINT 1000; ALTER TABLE hr.employees

DROP COLUMNS CONTINUE CHECKPOINT 1000;

Trang 20

Obtaining Table Information

Information about tables can be obtained by querying the following views:

DBA_TABLES

DBA_OBJECTS

Trang 21

In this lesson, you should have learned how to:

Distinguish between an extended versus a restricted ROWID

Outline the structure of a row

Create regular and temporary tables

Manage storage structures within a table

Reorganize, truncate, and drop a table

Drop a column within a table

Obtaining table information

Ngày đăng: 17/02/2014, 15:20

TỪ KHÓA LIÊN QUAN

w