默认情况 OceanBase 没有创建示例数据库 TPCC,需要手动创建。示例数据库必须在业务租户下创建。有关示例数据库介绍请参考“关于示例数据库 TPCC”。

租户创建好后,需要创建相应的Schema来存放示例数据库的对象,还要分配相应的用户和访问权限。

示例

  1. 通过obclient连接Oracle租户。具体方法请参考“通过obclient连接OceanBase租户”。
  1. $obclient -h192.168.1.101 -usys@t_oracle0_91#obdoc -P2883 -pabcABC123 sys
  2. obclient: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the OceanBase monitor. Commands end with ; or \g.
  4. Your OceanBase connection id is 58725
  5. Server version: 5.6.25 OceanBase 2.2.20 (…) (Built Aug 10 2019 15:27:33)
  6. <…省略…>
  7. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  8. obclient>
  1. 创建一个Schema,即用户。
  1. obclient> create user tpcc identified by 123456;
  2. Query OK, 0 rows affected (0.02 sec)
  3. obclient> grant all privileges on tpcc.* to tpcc;
  4. Query OK, 0 rows affected (0.02 sec)
  5. obclient> grant create,drop,select on *.* to tpcc;
  6. Query OK, 0 rows affected (0.01 sec)
  7. obclient> show grants for tpcc;
  8. +--------------------------------------------+
  9. | Grants for TPCC@% |
  10. +--------------------------------------------+
  11. | GRANT USAGE ON *.* TO 'TPCC' |
  12. | GRANT SELECT ON "SYS".* TO 'TPCC' |
  13. | GRANT ALL PRIVILEGES ON "TPCC".* TO 'TPCC' |
  14. +--------------------------------------------+
  15. 3 rows in set (0.01 sec)
  16. obclient>
  1. 通过用户tpcc登录到tpcc模式下。
  1. $obclient -h192.168.1.101 -utpcc@t_oracle0_91#obdoc -P2883 -p123456 tpcc
  1. 创建数据库对象
  1. obclient> source create_tables_oracle.sql
  2. Query OK, 0 rows affected (0.21 sec)
  3. <…省略…>
  4. Query OK, 0 rows affected (0.07 sec)
  5. +-----------+------------+-------------+-----------+
  6. | SYSDATE | TABLE_NAME | PARTITIONED | TEMPORARY |
  7. +-----------+------------+-------------+-----------+
  8. | 01-APR-20 | CUST | YES | N |
  9. | 01-APR-20 | DIST | YES | N |
  10. | 01-APR-20 | HIST | YES | N |
  11. | 01-APR-20 | ITEM | NO | N |
  12. | 01-APR-20 | LOAD_HIST | NO | N |
  13. | 01-APR-20 | LOAD_PROC | NO | N |
  14. | 01-APR-20 | NORD | YES | N |
  15. | 01-APR-20 | ORDL | YES | N |
  16. | 01-APR-20 | ORDR | YES | N |
  17. | 01-APR-20 | STOK | YES | N |
  18. | 01-APR-20 | WARE | YES | N |
  19. +-----------+------------+-------------+-----------+
  20. 11 rows in set (0.02 sec)
  1. 创建存储过程。
  1. obclient> source create_procedures_oracle.sql
  2. Query OK, 0 rows affected (0.08 sec)
  3. <…省略…>
  4. Query OK, 0 rows affected (0.03 sec)
  5. +-------------+-------------+---------------+--------+
  6. | OBJECT_NAME | OBJECT_TYPE | LAST_DDL_TIME | STATUS |
  7. +-------------+-------------+---------------+--------+
  8. | STOCKLEVEL | PROCEDURE | 01-APR-20 | VALID |
  9. | PAYMENT | PROCEDURE | 01-APR-20 | VALID |
  10. | DELIVERY | PROCEDURE | 01-APR-20 | VALID |
  11. | ORDERSTATUS | PROCEDURE | 01-APR-20 | VALID |
  12. | NEWORDER | PROCEDURE | 01-APR-20 | VALID |
  13. | STOCK_ITEM | VIEW | 01-APR-20 | VALID |
  14. +-------------+-------------+---------------+--------+
  15. 6 rows in set (0.03 sec)
  16. obclient>
  1. 初始化表数据。
  1. obclient> source init_data.sql
  2. Query OK, 0 rows affected (0.01 sec)
  3. <…省略…>
  4. Query OK, 0 rows affected (0.01 sec)
  5. Query OK, 1 row affected (0.00 sec)
  6. Query OK, 0 rows affected (0.03 sec)
  7. +------------+----------+
  8. | TABLE_NAME | ROWS_CNT |
  9. +------------+----------+
  10. | WARE | 2 |
  11. | DIST | 20 |
  12. | NORD | 40 |
  13. | ORDR | 60 |
  14. | HIST | 240 |
  15. | ITEM | 622 |
  16. | ORDL | 626 |
  17. | CUST | 1040 |
  18. | STOK | 1244 |
  19. +------------+----------+
  20. 9 rows in set (0.03 sec)