原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。
在数据库学习和开发过程中,示例库是不可或缺的工具。它们不仅帮助开发者熟悉数据库的基本操作,还能作为测试和学习的平台。GBase 8s 提供了两个示例库: stores_demo 和 superstores_demo ,这些示例库包含了很多表和数据,帮助用户快速上手。本文将介绍如何在 GBase 8s 中创建这两个示例库,并提供一些基本的使用建议。
1.创建stores_demo库:
在命令行执行 dbaccessdemo 命令:
[root@RHEL dbspaces]# dbaccessdemo
DBACCESS Demonstration Database Installation Script
Dropping existing stores_demo database ....
Creating stores_demo database ....
…
The creation of the demonstration database is now complete. The remainder of this script copies the examples into your current directory.
Press "Y" to continue, or "N" to abort.
n
[root@RHEL dbspaces]#
如上述所示,在运行完 dbaccessdemo 命令后会询问我们是否在当前目录下生成此命令所用到的所有sql文件,此处我们输入n并按回车,则不对sql文件进行生成。
2.创建superstores_demo库:
supersores_demo库的创建和stores_demo略有不同,需要先创建智能大对象空间,具体执行过程如下述:
[root@RHEL dbspaces]# cd $GBASEDBTDIR/dbspaces
[root@RHEL dbspaces]# touch s9_sbspc
[root@RHEL dbspaces]# chown gbasedbt:gbasedbt s9_sbspc
[root@RHEL dbspaces]# chmod 660 s9_sbspc
[root@RHEL dbspaces]# realpath s9_sbspc
/home/htr/gbase/351_3x2/dbspaces/s9_sbspc
[root@RHEL dbspaces]# onspaces -c -S s9_sbspc -p /home/htr/gbase/351_3x2/dbspaces/s9_sbspc -o 0 -s 40000
Your evaluation license will expire on 2025-12-30 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
此时,已经申请了智能大对象空间,可以运行dbaccessdemo9示例程序:
[root@RHEL dbspaces]# dbaccessdemo9
DBACCESS Demonstration Database Installation Script
Dropping existing superstores_demo database ....
Dropping existing sales_demo database ....
Creating superstores_demo database ....
Creating sales_demo database ....
Running dbaccessdemo9 requires that you have an sbspace named
s9_sbspc. If this sbspace doesn't exist the demo will fail. Please
make sure that this sbspace exists.
To create the sbspace run the following as user gbasedbt. ( Note the
permissions for sbspace must be 660 )
onspaces -c -S s9_sbspc -p <PATH> -o 0 -s 4000
where PATH is the location of file in which the sbspace will be created.
Are you sure that sbspace s9_sbspc exists (Y/N) ?
y
…
The creation of the demonstration database is now complete. The remainderof this script copies the examples into your current directory.
Press "Y" to continue, or "N" to abort.
n
在运行过程中会提示需要s9_sbspc空间,我们在此前已经创建,此处输入y并回车。末尾处提示与stores_demo库的提示一致,此处输入n并回车。此时,superstores_demo库已成功创建。
3.stores_demo库与superstores_demo库简要描述:
stores_demo 数据库包含描述虚构业务的一组表,且 GBase 8s 文档中的许多示例基于此数据库。 superstores_demo数据库举例说明了对象关系模式。
stores_demo 库及superstores_demo库均使用缺省(美国英语)语言环境并且不符合 ANSI 标准。尽管superstores_demo 数据库中许多表具有与stores_demo 表相同的名称,但它们并不相同。
下图显示stores_demo库中各表之间的连接关系:
Customer_ts_data、 ts_data 和 ts_data_location 表包含时间系列数据。
下图显示 stores_demo 数据库中客户、电表数据和位置之间的连接:
下图显示如何关联 superstores_demo 数据库的分层表。
两个表之间的外键和主键关系由从 customer.custnum 和 customer.loc 列指向 location.location_id 列的阴影箭头指示。
以上,本文的介绍了如何在 GBase 8s 中创建 stores_demo 和 superstores_demo 两个示例库。这些示例库包含很多表和数据,能帮助你快速熟悉 GBase 8s 的基本操作和功能。希望这些内容能帮助你在学习和开发过程中更加高效。如果你在创建示例库的过程中遇到任何问题,欢迎随时在社区中提问,我们在这里为你提供支持!
原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。