Database Object: by Team Teaching
Database Object: by Team Teaching
By
Team Teaching
Agenda
■ Schema
■ Database Objects
■ Alias
■ Table Types
– Regular Table
– Temporary Table
– Materialized Query Table (MQT)
– View
– Historical Table
■ Indexes
■ Sequences
DB2 Object Hierarchy
Schemas
■ There are some restrictions and recommendations that you must be aware
of when naming schemas.
– User-defined types (UDTs) cannot have schema names longer than the
schema length listed in SQL and XML limits.
– The following schema names are reserved words and must not be used:
SYSCAT, SYSFUN, SYSIBM, SYSSTAT, SYSPROC.
– To avoid potential problems upgrading databases in the future, do not
use schema names that begin with SYS. The database manager will not
allow you to create modules, procedures, triggers, user-defined types
or user-defined functions using a schema name beginning with SYS.
– It is recommended that you not use SESSION as a schema name.
Declared temporary tables must be qualified by SESSION. It is therefore
possible to have an application declare a temporary table with a name
identical to that of a persistent table, in which case the application
logic can become overly complicated. Avoid the use of the schema
SESSION, except when dealing with declared temporary tables.
CREAT SCHEMA
STATEMENT
■ CREATE SCHEMA NAMA_SCHEMA
■ CONTOH :
– CREATE SCHEMA AKADEMIK
Set current schema
■ Base tables
– These types of tables hold persistent data. There are
different kinds of base tables, including
■ Regular tables
– Regular tables with indexes are the "general purpose"
table choice.
■ Multidimensional clustering (MDC) tables (dwh)
■ Range-clustered tables (RCT) (dwh)
■ Partitioned tables (dwh)
■ Temporary tables
■ Materialized query tables
■ View
■ Hisotry Table
CREATE REGULAR TABLE
connect to musicdb;
create table artists
(artno smallint not null,
name varchar(50) with default 'abc',
classification char(1) not null,
bio clob(100K) logged,
picture blob( 10M) not logged compact)
in dms01
index in dms02
long in dms03;
Data types
Large Objects