使用 DB2 pureXML 和 PHP 构建 Support Knowledge Base(上)
2010-02-25 00:00:00 来源:WEB开发网Start > Programs > IBM DB2 > DB2COPY1 (Default) > Command Line Tools > Command Editor
图 1. DB2 Command Editor
PHP 构建 Support Knowledge Base(上)" border="0" onload="return imgzoom(this,550);" style="cursor:pointer;" onclick="javascript:window.open(this.src);"/>
Command Editor 的主界面分为两个部分。上面的部分是编辑区。可以在此区域输入希望对数据库发出的命令。底部是结果区。这个区域将显示在编辑区执行完语句后数据库的响应消息。
将清单 1 中的代码复制并粘贴到 DB2 Command Editor 的编辑区。单击编辑区中的工具栏左侧的绿色箭头按钮,执行代码。需要等待一段时间,因为代码执行需要大概一分钟左右的时间才能完成。
清单 1. database.sql
CREATE DATABASE kbase USING CODESET UTF-8 TERRITORY us;
CONNECT TO kbase;
CREATE TABLE category (
id int not null generated by default as identity,
data xml not null,
primary key(id)
);
CREATE TABLE article (
id int not null generated by default as identity,
date_created timestamp not null,
date_modified timestamp not null,
view_count int,
category_id int not null,
data xml not null,
primary key(id),
foreign key(category_id) references category(id)
on delete cascade
);
CREATE TABLE comment (
id int not null generated by default as identity,
date_left timestamp not null,
approved smallint not null,
article_id int not null,
data xml not null,
primary key(id),
foreign key(article_id) references article(id)
on delete cascade
);
CREATE TABLE rating (
id int not null generated by default as identity,
date_rated timestamp not null,
article_id int not null,
data xml not null,
primary key(id),
foreign key(article_id) references article(id)
on delete cascade
);
更多精彩
赞助商链接