4.创建数据库对象
在创建完数据库、用户并进行了授权之后,接下来将创建用户数据库对象。create_tables.sql脚本如下:
/* ============================================================ */
/* Table: service */
/* ============================================================ */
create table service
(
service_key int not null,
call_waiting_flag char(1) null ,
caller_id_flag char(1) null ,
voice_mail_flag char(1) null ,
cellular_flag char(1) null ,
internet_flag char(1) null ,
isdn_flag char(1) null ,
primary key (service_key)
);
/* ============================================================ */
/* Table: month */
/* ============================================================ */
create table month
(
month_key int not null,
month_text char(9) null ,
month_number int null ,
fiscal_period char(2) null ,
year int null ,
period_and_year char(7) null ,
month_and_year char(7) null ,
primary key (month_key)
);
/* ============================================================ */
/* Table: customer */
/* ============================================================ */
create table customer
(
customer_key int not null,
customer_first_name char(11) null ,
customer_last_name char(15) null ,
customer_gender char(1) null ,
street_address char(18) null ,
city char(20) null ,
state char(2) null ,
postal_code char(9) null ,
phone_number char(10) null ,
primary key (customer_key)
);
/* ============================================================ */
/* Table: status */
/* ============================================================ */
create table status
(
status_key int not null,
new_customer char(1) null ,
new_address char(1) null ,
call_waiting_status char(10) null ,
caller_id_status char(10) null ,
voice_mail_status char(10) null ,
cellular_status char(10) null ,
internet_status char(10) null ,
isdn_status char(10) null ,
closed_this_period char(1) null ,
primary key (status_key)
);
/* ============================================================ */
/* Table: telco_facts */
/* ============================================================ */
create table telco_facts
(
month_key int not null,
customer_key int not null,
service_key int not null,
status_key int not null,
combined_revenue money null ,
number_of_lines int null ,
local_call_count int null ,
local_call_minutes int null ,
long_distance_call_count int null ,
long_distance_call_minutes int null ,
minutes_online int null ,
primary key (month_key,customer_key,service_key,status_key),
);
有了创建数据库对象的脚本,具体怎么执行呢?按照下面的步骤即可:
(1) 使用dbisql执行建表脚本create_tables.sql
dbisql -c "uid=mpuser;pwd=mpuserpwd;eng=mp2" -nogui create_tables.sql