SAP MaxDB学习笔记

MaxDB 文档 <!-- @page { size: 21cm 29.7cm; margin: 2cm } H1 { margin-top: 0.6cm; margin-bottom: 0.58cm; line-height: 200%; page-break-inside: avoid; page-break-after: avoid } H1.western { font-size: 22pt; font-weight: bold } H1.cjk { font-size: 22pt; font-weight: bold } H2 { margin-top: 0.46cm; margin-bottom: 0.46cm; line-height: 172%; page-break-inside: avoid; page-break-after: avoid } H2.western { font-family: "Arial", sans-serif; font-size: 16pt; font-weight: bold } H2.cjk { font-family: "黑体"; font-size: 16pt; font-weight: bold } P { margin-top: 0cm; margin-bottom: 0.21cm } -->

MaxDB 文档

  1. 安装

可以使用安装管理器来进行安装,安装管理器是一个图形化的安装工具,安装软件的需求如下:

Prerequisites for Using the Installation Manager

Platform

wxWidget Software

Other Software

MS Windows X86_32

wxMSW

-

MS Windows X86_64, IA64

Not yet supported

-

Linux X86_32

wxGTK2

Gtk+ >= 2.0

glibc ≥ 2.3.3 with TLS support (Thread Local Storage)

If gcc 4.x is installed on your system, you may also require libstdc compatibility libraries for gcc 3.2.x or gcc 3.3.x.

*Linux X86_64

wxGTK2

glibc ≥ 2.3.3

Gtk+ >= 2.0

*Linux IA64

wxGTK2

glibc ≥ 2.3.3

Gtk+ >= 2.0

*Linux PPC_64

wxGTK2

glibc ≥ 2.3.3

Gtk+ >= 2.0

SUN Solaris SPARC

wxGTK

Gtk+ 1.2 (included from Solaris 9 onwards)

IBM AIX PPC_64

wxGTK (Gtk statically linked)

X11 running time

HP-UX HPPA

wxGTK (Gtk statically linked)

X11 running time

HP-UX IPF

wxGTK (Gtk statically linked)

X11 running time


unix 环境下安装步骤如下:

  1. root 登录shell

  2. 转到home root 目录解压数据库软件

  3. 运行命令 ./SDBSETUP

  4. 安装完成后更新系统环境变量 ex port PATH=/opt/sdb/programs/bin:$PATH

  5. 可以将以上内容写入到 .bash_profile

让数据库实例在 linux 启动的时候自动启动

Prerequisites

· You have created the database instance DEMODB and the DBM operator OLEG with the password MONDAY.

· You are in a root shell.

Procedure

...

1. Save the maxdb start script in the directory /etc/init.d

2. Go to the directory /etc/rc3.d

3. Create the following symbolic links:

ln -s ../init.d/maxdb K05maxdb

ln -s ../init.d/maxdb S18maxdb

maxdb Start Script

#! /bin/sh

# Copyright (c) 2001-2004 SAP AG, Germany.

#

# Author: <[email protected]>

#

# init.d/maxdb

#

# and symbolic its link

#

#

### BEGIN INIT INFO

# Provides: MaxDB

# Required-Start: $remote_fs $syslog

# Required-Stop: $remote_fs $syslog

# Default-Start: 3 5

# Default-Stop: 0 1 2 6

# Description: Start MaxDB communication server.

### END INIT INFO


if [ -f /etc/rc.config ]; then

. /etc/rc.config

fi


# where to find x_server executable

IND_PROG_DBROOT=""

if [ -f /etc/opt/sdb ]; then

IND_PROG_DBROOT=`grep '^IndepPrograms=' /etc/opt/sdb | sed 's:IndepPrograms=::g'`

else

exit 5

fi

X_SERVER=$IND_PROG_DBROOT/bin/x_server

X_PATH=$IND_PROG_DBROOT/bin



MaxDB_BIN=$X_SERVER

test -x $MaxDB_BIN || exit 5


MaxDB_BIN=$X_PATH/dbmcli

test -x $MaxDB_BIN || exit 5


# find program fuser

FUSER=/bin/fuser

test -x $FUSER || FUSER=/sbin/fuser

test -x $FUSER || FUSER=/usr/sbin/fuser



# Shell functions sourced from /etc/rc.status:

# rc_check check and set local and overall rc status

# rc_status check and set local and overall rc status

# rc_status -v ditto but be verbose in local rc status

# rc_status -v -r ditto and clear the local rc status

# rc_failed set local and overall rc status to failed

# rc_reset clear local rc status (overall remains)

# rc_exit exit appropriate to overall rc status

#. /etc/rc.status


# First reset status of this service

#rc_reset


# Return values acc. to LSB for all commands but status:

# 0 - success

# 1 - misc error

# 2 - invalid or excess args

# 3 - unimplemented feature (e.g. reload)

# 4 - insufficient privilege

# 5 - program not installed

# 6 - program not configured

# 7 - program is not running

#

# Note that starting an already running service, stopping

# or restarting a not-running service as well as the restart

# with force-reload (in case signalling is not supported) are

# considered a success.


RETVAL=1

case "$1" in

start)

echo -n "Starting MaxDB services: "

if [ ! -z "$X_SERVER" ]; then

$X_SERVER start>/dev/null 2>&1


# to enable auto start/stop demodb remove following comments


DBMCLI=$X_PATH/dbmcli

if [ ! -x $DBMCLI ]; then

echo "dbmcli not found" >&2

exit 5

fi

$DBMCLI -d DEMODB << __EOD__ 2>&1 > /dev/null

user_logon OLEG,MONDAY

db_online

__EOD__

_test=`echo $_o | grep ERR`

if [ "$_test" = "" ]; then

echo -n " database DEMODB started"

else

echo "cannot start DEMODB: $_o" >&2

exit 7

fi


RETVAL=0


fi

touch /var/lock/subsys/maxdb

;;

stop)

echo -n "Shutting down MaxDB services: "

if [ ! -z "$X_SERVER" ]; then

# to enable auto start/stop demodb remove following comments

DBMCLI=$X_PATH/dbmcli

if [ ! -x $DBMCLI ]; then

echo "dbmcli not found" >&2

exit 5

fi

_o=`$DBMCLI -d DEMODB << __EOD__ 2>&1

user_logon OLEG,MONDAY

db_offline

__EOD__`

_test=`echo $_o | grep ERR`

if [ "$_test" = "" ]; then

echo -n "database DEMODB stopped"

else

echo "cannot stop DEMODB: $_o" >&2

exit 1

fi


$X_SERVER stop > /dev/null 2>&1


RETVAL=0

fi

rm -f /var/lock/subsys/maxdb

;;

status)

if [ ! -z "$X_PATH" ]; then

if [ -x $FUSER ]; then

_o=`$FUSER $IND_PROG_DBROOT/pgm/vserver`

if [ $? -eq 0 ]; then

echo "communication server is running"

# to enable auto start/stop demodb remove following comments

DBMCLI=$X_PATH/dbmcli

if [ ! -x $DBMCLI ]; then

echo "dbmcli not found" >&2

exit 5

fi

_o=`$DBMCLI -d DEMODB << __EOD__

user_logon OLEG,MONDAY

db_state

__EOD__`

_test=`echo $_o | grep ERR`

if [ "$_test" = "" ]; then

_state=`echo $_o | sed s/.*State/ *// | sed s// .*//`

echo "database DEMODB is $_state"

else

echo "cannot get state of DEMODB: $_o" >&2

fi

RETVAL=0

else

echo "communication server is not running"

RETVAL=0

fi

else

echo "status unkown - fuser not found" >&2

fi

else

echo "status unkown - x_server not found" >&2

fi

;;

restart)

$0 stop

$0 start

;;

reload)

$0 stop

$0 start

;;

*)

echo "Usage: maxdb {start|stop|status|reload|restart}"

exit 1

;;

esac


exit $RETVAL

系统支持的系统版本和架构:

MaxDB 7.6: Supported Operating Systems and Architectures

Operating System Supplier

Operating System Versions

Architectures

IBM

AIX 5.2

AIX 5.3

64bit

64bit

HP

HP-UX 11.11


HP-UX 11.23

PA-RISC 64bit


PA-RISC 64bit

IA64 64bit

Red Hat

Red Hat EL 4

IA32 32bit

x86_64 64bit

Sun

Solaris 9


Solaris 10

SPARC 64bit


SPARC 64bit

x64 64bit

Novell

SUSE SLES9

IA32 32bit

IA64 64bit

x86_64 64bit

Power 64bit

Microsoft

Windows 2000 Professional


Windows XP Professional


Windows Server 2003

IA32 32bit


IA32 32bit


IA32 32bit

IA64 64bit

x64 64bit



  1. 基础信息

安装使用 demodb damo 数据库实例名: demodb system administration 的名称与密码: dbadmin/secret

Name of the demo database instance: DEMODB

Name/password of the database system administrator: DBADMIN/SECRET

Name/password of a database user: MONA/RED

Schema: HOTEL

使用备份和恢复工具,备份恢复工具结构图如下:


导入导出数据结构图:


使用备份工具支持 oracle 数据库,但是最低 maxdb 版本必须是 7.5. 使用 backint for oracle interface

MaxDB Versions and Tools for Creating Backups and Restoring by Using a Backint for Oracle Interface

Version

Build No.

Available MaxDB Tools

7.4.03

from 000

Database Manager CLI, Database Manager GUI

from 002

Also Web DBM

7.4.02

from 000

Database Manager CLI, Database Manager GUI

from 011

Also Web DBM

7.4.01

from 003

Database Manager CLI, Database Manager GUI

7.3.32

from 000

Database Manager CLI, Database Manager GUI

7.3.00

from 015

Database Manager CLI, Database Manager GUI

from 025

Also Web DBM

7.2.05

from 008

Database Manager CLI,
Database Manager GUI (Backups only)
*

我们可以连接到TSM 软件来进行备份和恢复。

设置环境变量

Use

So that the Database Manager and the Loader on the database computer can access the required environment variables ADINT and ADA_OPT , you have to explicitly define them by using the Database Manager CLI.

Environment Variable

Description

ADINT

Specifies the directory in which the program adint2 (UNIX) or adint2.exe (Microsoft Windows) is stored. Specify this directory as an absolute path – without a closing slash (/) or backslash (/).

ADA_OPT

Absolute name of the adint2 configuration file. An example configuration file initSID.utl is located in the directory of the adint2 program.

Syntax

dbmcli -d <database_name> -n <database_computer> -u <dbm_operator>,<dbm_operator_password> dbm_configset -raw <variable> <value>

<variable>

Environment variable
ADINT | ADA_OPT

<value>

Value of the environment variable

连接使用demo 数据,建表建数据。

CREATE TABLE city

(zip CHAR (5) PRIMARY KEY CONSTRAINT zip_cons CHECK

SUBSTR (zip,1,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,2,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,3,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,4,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,5,1) BETWEEN '0' AND '9',

name CHAR (30) NOT NULL ,

state CHAR (2) NOT NULL )

-----------------------------------------------------------------------------------

CREATE TABLE customer

(cno FIXED (4) PRIMARY KEY CONSTRAINT cno_cons CHECK cno > 0,

title CHAR (7) CONSTRAINT title_cons CHECK title IN ('Mr', 'Mrs', 'Company'),

firstname CHAR (20),

name CHAR (40) NOT NULL ,

zip CHAR (5) CONSTRAINT zip_cons CHECK

SUBSTR (zip,1,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,2,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,3,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,4,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,5,1) BETWEEN '0' AND '9',

address CHAR (40) NOT NULL ,

FOREIGN KEY customer_zip_in_city (zip) REFERENCES city ON DELETE RESTRICT )

------------------------------------------------------------------------------------

CREATE TABLE hotel

(hno FIXED (4) PRIMARY KEY CONSTRAINT hno_cons CHECK hno > 0,

name CHAR (50) NOT NULL ,

zip CHAR (5) CONSTRAINT zip_cons CHECK

SUBSTR (zip,1,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,2,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,3,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,4,1) BETWEEN '0' AND '9' AND

SUBSTR (zip,5,1) BETWEEN '0' AND '9',

address CHAR (40) NOT NULL ,

info LONG ,

FOREIGN KEY hotel_zip_in_city (zip) REFERENCES city ON DELETE RESTRICT )

-------------------------------------------------------------------------------

CREATE TABLE room

(hno FIXED (4) CONSTRAINT hno_cons CHECK hno > 0,

type CHAR (6) CONSTRAINT type_cons CHECK type IN ('single','double','suite'), PRIMARY KEY (hno, type ),

free FIXED (3,0) CONSTRAINT free_cons CHECK free >= 0,

price FIXED (6,2) CONSTRAINT price_cons CHECK price BETWEEN 0.00 AND 5000.00,

FOREIGN KEY room_hno_in_hotel (hno) REFERENCES hotel ON DELETE CASCADE )

------------------------------------------------------------------------------------------

CREATE TABLE reservation

(rno FIXED (4) PRIMARY KEY CONSTRAINT rno_cons CHECK rno > 0,

cno FIXED (4) CONSTRAINT cno_cons CHECK cno > 0,

hno FIXED (4) CONSTRAINT hno_cons CHECK hno > 0,

type CHAR (6) CONSTRAINT type_cons CHECK type IN ('single','double','suite'),

arrival DATE NOT NULL ,

departure DATE NOT NULL , CONSTRAINT staying CHECK departure > arrival,

FOREIGN KEY reservation_cno_in_customer (cno) REFERENCES customer ON DELETE CASCADE

FOREIGN KEY reservation_info_in_room (hno, type ) REFERENCES room ON DELETE CASCADE )

-------------------------------------------------------------------------------------------------

CREATE TABLE employee

(hno FIXED (4),

eno FIXED (4), PRIMARY KEY (hno,eno),

title CHAR (7) CONSTRAINT title_cons CHECK title IN ('Mr','Mrs'),

firstname CHAR (20),

name CHAR (20) NOT NULL ,

manager_eno FIXED (4),

FOREIGN KEY employee_hno_in_hotel (hno) REFERENCES hotel ON DELETE CASCADE )

-----------------------------------------------------------------------------------------

视图创建

CREATE VIEW customer_addr (cno, title, name , zip, city, state , address )

AS SELECT customer.cno, customer.title, customer.name, customer.zip,

city.name, city.state, customer.address

FROM customer, city

WHERE customer.zip = city.zip WITH CHECK OPTION

--------------------------------------------------------------------------------------------

CREATE VIEW hotel_addr (hno, name , zip, city, state , address )

AS SELECT hotel.hno, hotel.name, hotel.zip,

city.name, city.state, hotel.address

FROM hotel, city

WHERE hotel.zip = city.zip WITH CHECK OPTION

-------------------------------------------------------------------------------------------------

CREATE VIEW custom_hotel (customname, customcity, hotelname, hotelcity)

AS SELECT customer_addr.name, customer_addr.city,

hotel_addr.name, hotel_addr.city

FROM customer_addr, hotel_addr, reservation

WHERE customer_addr.cno = reservation.cno

AND hotel_addr.hno = reservation.hno

-------------------------------------------------------------------------------------------------

索引

CREATE INDEX city_state ON city ( state )

CREATE INDEX full_name_index ON customer (surname, first name )

-------------------------------------------------------------------------------------------------

  1. 教程

数据库管理教程

使用dbm command line interface 登录

Enter server name: localhost

Enter database name: maxdb1

Enter user for authorization: dbadmin

Enter password:

C:/sdb/programs/pgm/dbmcli.exe on localhost : maxdb1>

1. Call the Database Manager CLI, create the new database instance DEMODB , define the first DBM operator with user name DBM and password DBM .

>dbmcli db_create DEMODB DBM,DBM

OK

Alternative command lines:

If you have several versions of the database software installed on your computer, you need to enter additional information. Use the option -R <dependent_path> to specify the version for which you want to create the database instance:

>dbmcli -R "C:/Program Files/SDB/7.6.00" db_create DEMODB DBM,DBM

2. Call the Database Manager CLI in session mode, log on as operator DBM with the password DBM , connect to the database instance DEMODB :

>dbmcli –u DBM,DBM -d DEMODB

dbmcli on DEMODB>

3. Open a parameter session:

>param_startsession

OK

dbmcli on DEMODB>

4. Initialize the database parameters and define the database type OLTP (default value).

>param_init

OK

dbmcli on DEMODB>

5. Change the database parameter SESSION_TIMEOUT to the value 0 .

dbmcli on DEMODB>param_put SESSION_TIMEOUT 0

OK

6. Change the database parameter _UNICODE to the value YES

dbmcli on DEMODB>param_put _UNICODE YES

OK

7. Change the database parameter _SERVERDB_FOR_SAP to the value 0 .

dbmcli on DEMODB>param_put _SERVERDB_FOR_SAP NO

OK

8. Change the database parameter MAXDATAVOLUMES to the value 64 :

dbmcli on DEMODB>param_put MAXDATAVOLUMES 64

OK

9. Change the database parameter MAXUSERTASKS to the value 10 :

dbmcli on DEMODB>param_put MAXUSERTASKS 10

OK

10. Check all database parameters:

dbmcli on DEMODB>param_checkall

OK

11. Confirm changes to the database parameter file:

dbmcli on DEMODB>param_commitsession

OK

12. Create data and log volumes

a. Create data volume No. 1 with name DISKD0001 , type FILE , size 32768 pages:

dbmcli on DEMODB>param_addvolume 1 DATA DISKD0001 F 32768

OK

b. Create log volume No. 1 with name DISKL0001 , type FILE , size 6400 pages

dbmcli on DEMODB>param_addvolume 1 LOG DISKL0001 F 6400

OK

13. Transfer the database instance to the ADMIN operational state:

dbmcli on DEMODB>db_admin

OK

14. Initialize the new database instance and create the database system administrator with user name DBADMIN and password SECRET :

dbmcli on DEMODB>db_activate DBADMIN,SECRET

OK

15. Load the system tables:

dbmcli on DEMODB>load_systab

OK

0,OK: everything works fine

0,""c:/program files/sdb/maxdb1/bin/x_python" "c:/program files/sdb/maxdb1/env

/lsystab.py" -R "c:/program files/sdb/maxdb1" -d DEMODB -u dbadmin,*"

Removing obsolete objects

Installing Loader tables

...

...

==================================

Installation successfully finished

==================================

16. Switch on automatic update of optimizer statistics function:

dbmcli on DEMODB>auto_update_statistics ON

OK

17. Switch on automatic extension of data area function:

dbmcli on DEMODB>auto_extend ON

OK

18. Load the demo data:

dbmcli on DEMODB>load_tutorial

OK

0,OK: everything works fine

0,""c:/program files/sdb/maxdb1/bin/x_python" "c:/program files/sdb/maxdb1/env

/../demo/ltutorial.py" -R "c:/program files/sdb/maXdb1" -d DEMODB -u dbadmin,*"

HOTEL

==================================

Installation successfully finished

==================================

19. Switch on overwrite mode for the log area:

dbmcli on DEMODB>db_execute SET LOG AUTO OVERWRITE ON

OK

使用脚本方式进行demodb 管理

1. Create the script file demoscript.txt and save it here:

C:/test/DBM

2. Copy the following template to the script file and save your entries:

db_create DEMODB DBM,DBM

param_startsession

param_init OLTP

param_put SESSION_TIMEOUT 0

param_put _UNICODE YES

param_put CACHE_SIZE 2500

param_put _SERVERDB_FOR_SAP NO

param_put MAXDATAVOLUMES 64

param_put MAXUSERTASKS 10

param_checkall

param_commitsession

param_addvolume 1 DATA DISKD0001 F 32768

param_addvolume 1 LOG DISKL0001 F 6400

db_admin

db_activate DBADMIN,SECRET

load_systab

auto_update_statistics ON

auto_extend ON

load_tutorial

db_execute SET LOG AUTO OVERWRITE ON

3. Call the Database Manager CLI with the option for executing the script file:

...

>dbmcli -i "C:/test/DBM/demoscript.txt"

>db_create DEMODB DBM,DBM

OK


---

>param_startsession

OK


---

>param_init OLTP

OK


---

>param_put SESSION_TIMEOUT 0

OK


---

>param_put _UNICODE YES

OK


---

>param_put CACHE_SIZE 2500

OK


---

>param_put _SERVERDB_FOR_SAP NO

OK


---

>param_put MAXDATAVOLUMES 64

OK


---

>param_put MAXUSERTASKS 10

OK


---

>param_checkall

OK


---

>param_commitsession

OK


---

>param_addvolume 1 DATA DISKD0001 F 32768

OK


---

>param_addvolume 1 LOG DISKL0001 F 6400

OK


---

>db_admin

OK


---

>db_activate DBADMIN,SECRET

OK


---

>auto_update_statistics ON

OK


---

>auto_extend ON

OK


---

>load_systab

OK

0,OK: everything works fine

0,""c:/program files/sdb/maxdb1/bin/x_python" "c:/program files/sdb/maxdb1/env/lsystab.py" -R "c:/program files/sdb/maxdb1" -d DEMODB -u DBADMIN,*"

Removing obsolete objects

Installing Loader tables

Installing messages and help

Installing SYSDBA tables

Installing comments for SYSDBA tables

Installing precompiler tables

Installing system tables for R3 backup information

Installing ODBC tables

Installing system tables for ORACLE (V7) mode

Installing data dictionary tables and views

Installing synonyms for oracle system tables

Installing comments on oracle system tables

Installing tables for WebAgent

Installing tables for Repository

Installing DOMAIN tables

Installing comments for DOMAIN tables

Installing Views as replacement for SHOWs

Installing Database Manager tables

Installing SYSINFO tables

Installing comments for SYSINFO tables

Installing support for UDE (User Defined Extensions)

Installing tables for JDBC Database Metadata

Installing tables for SQLDBC Database Metadata

Installing additional triggers

==================================

Installation successfully finished

==================================


---

>load_tutorial

OK

0,OK: everything works fine

0,""c:/program files/sdb/maxdb1/bin/x_python" "c:/program files/sdb/maxdb1/env/../demo/ltutorial.py" -R "c:/program files/sdb/maxdb1" -d DEMODB -u DBADMIN,*

"

HOTEL

==================================

Installation successfully finished

==================================


---

>db_execute SET LOG AUTO OVERWRITE ON

OK

以上工作包含以下工作内容:

  1. 自动更新数据库实例状态

  2. 自动展开数据区域

  3. 加载系统表

  4. 加载demo 数据

  5. 日志覆盖切换

删除数据库实例:

C:/sdb/DBM>dbmcli -i demoscript.txt

>db_create DEMODB DBM,DBM

ERR

-24953,ERR_DBEXIST: Database instance DEMODB already exists

---

C:/sdb/DBM>dbmcli -u dbm,dbm -d demodb

dbmcli on demodb>db_offline

OK

---

dbmcli on demodb>db_drop

OK

---

  1. 工具

  2. 接口

  3. 开发

你可能感兴趣的:(学习笔记)