【IT168 技术】接上篇:数据库技巧:MonetDB上运行TPC-H(下)
6. 运行MonetDB安装目录下的merovingian,该程序为管理数据库的程序,参考如下:
MonetDB用于执行管理数据库系统的多个操作,它可以检查数据库服务器的稳定性,也能够临时对外关闭数据库作维护,允许作检查点等。MonetDB创建数据库命令如下:
shell> monetdb create test
successfully created database 'test'
successfully created database 'test'
检查数据库状态:
shell> monetdb status
name state uptime health last crash
test locked
name state uptime health last crash
test locked
这说明数据库存在但是还没有运行,可以用"start"命令选项开启数据库。注意,此时数据库仍然处理维护状态(lock)。
shell> monetdb start test
starting database 'test'... done
shell> monetdb status test
name state uptime health last crash
test locked 5s 100%, 0s -
starting database 'test'... done
shell> monetdb status test
name state uptime health last crash
test locked 5s 100%, 0s -
由于数据库仍然处于维护状态,只有数据管理员才能够连接数据库,对于其它用户,数据库必须用命令release开 For example, the statements below illustrate a short session of the creation of a new user. The session is closed using the mclient console command \q.
shell> mclient -l sql -d test –umonetdb –Pmonetdb
sql>CREATE USER "tpc" WITH PASSWORD 'tpc' NAME 'TPC Explorer' SCHEMA "sys";
sql>CREATE SCHEMA "tpc" AUTHORIZATION "tpc";
sql>ALTER USER "tpc" SET SCHEMA "tpc";
sql>\q
sql>CREATE USER "tpc" WITH PASSWORD 'tpc' NAME 'TPC Explorer' SCHEMA "sys";
sql>CREATE SCHEMA "tpc" AUTHORIZATION "tpc";
sql>ALTER USER "tpc" SET SCHEMA "tpc";
sql>\q
7. 然后启动test数据库,使用客户端进入
shell> mclient -l sql -d test –utpc
sql>
sql>
8. 创建TPC-H所需的数据库表,在DBgen程序所在目录下,有一个dss.dll文件,该文件是TPC-H的建表文件,使用如下命令,将dss.ddl导入monedDB执行该文件里的SQL语句:
Sql> \< /yourdicrector/dss.ddl
建好后,使用
Sql> \d
查看当前已有的数据表信息。
sql>\d
TABLE tpc.customer
TABLE tpc.lineitem
TABLE tpc.nation
TABLE tpc.orders
TABLE tpc.part
TABLE tpc.partsupp
TABLE tpc.region
TABLE tpc.supplier
TABLE tpc.customer
TABLE tpc.lineitem
TABLE tpc.nation
TABLE tpc.orders
TABLE tpc.part
TABLE tpc.partsupp
TABLE tpc.region
TABLE tpc.supplier