在 obclient 命令行环境里,可以通过一些命令或者 SQL 查看数据库对象或者表属性和数据。

示例

  • 通过 obclient 查看 Oracle 租户下 TPCC 模式下的数据库对象。
  1. $obclient -h192.168.1.101 -utpcc@t_oracle0_91#obdoc -P2883 -p123456 tpcc
  2. obclient> select object_type,count(*) from user_objects group by object_type;
  3. +-----------------+----------+
  4. | OBJECT_TYPE | COUNT(*) |
  5. +-----------------+----------+
  6. | TABLE | 15 |
  7. | INDEX | 2 |
  8. | VIEW | 1 |
  9. | TABLE PARTITION | 48 |
  10. | PROCEDURE | 5 |
  11. +-----------------+----------+
  12. 5 rows in set (0.01 sec)
  • 通过 obclient 查看 TPCC 模式下的表属性
  1. obclient> desc ordl;
  2. +----------------+-------------+------+-----+---------+-------+
  3. | FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA |
  4. +----------------+-------------+------+-----+---------+-------+
  5. | OL_W_ID | NUMBER(38) | NO | PRI | NULL | NULL |
  6. | OL_D_ID | NUMBER(38) | NO | PRI | NULL | NULL |
  7. | OL_O_ID | NUMBER(38) | NO | PRI | NULL | NULL |
  8. | OL_NUMBER | NUMBER(38) | NO | PRI | NULL | NULL |
  9. | OL_DELIVERY_D | DATE | YES | NULL | NULL | NULL |
  10. | OL_AMOUNT | NUMBER(6,2) | YES | NULL | NULL | NULL |
  11. | OL_I_ID | NUMBER(38) | YES | NULL | NULL | NULL |
  12. | OL_SUPPLY_W_ID | NUMBER(38) | YES | NULL | NULL | NULL |
  13. | OL_QUANTITY | NUMBER(38) | YES | NULL | NULL | NULL |
  14. | OL_DIST_INFO | CHAR(24) | YES | NULL | NULL | NULL |
  15. +----------------+-------------+------+-----+---------+-------+
  16. 10 rows in set (0.00 sec)
  17. obclient> show create table ordl\G
  18. *************************** 1. row ***************************
  19. TABLE: ORDL
  20. CREATE TABLE: CREATE TABLE "ORDL" (
  21. "OL_W_ID" NUMBER(38) NOT NULL,
  22. "OL_D_ID" NUMBER(38) NOT NULL,
  23. "OL_O_ID" NUMBER(38) NOT NULL,
  24. "OL_NUMBER" NUMBER(38) NOT NULL,
  25. "OL_DELIVERY_D" DATE,
  26. "OL_AMOUNT" NUMBER(6,2),
  27. "OL_I_ID" NUMBER(38),
  28. "OL_SUPPLY_W_ID" NUMBER(38),
  29. "OL_QUANTITY" NUMBER(38),
  30. "OL_DIST_INFO" CHAR(24),
  31. CONSTRAINT "ORDL_OBPK_1581557270705134" PRIMARY KEY ("OL_W_ID", "OL_D_ID", "OL_O_ID", "OL_NUMBER")
  32. ) COMPRESS FOR QUERY REPLICA_NUM = 3 BLOCK_SIZE = 16 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 TABLEGROUP = 'TPCC_GROUP'
  33. partition by hash(ol_w_id) partitions 6
  34. 1 row in set (0.00 sec)
  35. obclient> show create tablegroup TPCC_GROUP\G
  36. *************************** 1. row ***************************
  37. TABLEGROUP: TPCC_GROUP
  38. CREATE TABLEGROUP: CREATE TABLEGROUP "TPCC_GROUP" BINDING = FALSE
  39. partition by hash partitions 6
  40. 1 row in set (0.00 sec)
  • 通过 obclient 查看 TPCC 模式下的表数据
  1. obclient> select * from ordr where rownum<3;
  2. +--------+--------+------+--------+--------------+----------+-------------+-----------+
  3. | O_W_ID | O_D_ID | O_ID | O_C_ID | O_CARRIER_ID | O_OL_CNT | O_ALL_LOCAL | O_ENTRY_D |
  4. +--------+--------+------+--------+--------------+----------+-------------+-----------+
  5. | 2 | 1 | 2100 | 2360 | 10 | 8 | 1 | 15-FEB-20 |
  6. | 2 | 1 | 2101 | 2101 | NULL | 14 | 1 | 15-FEB-20 |
  7. +--------+--------+------+--------+--------------+----------+-------------+-----------+
  8. 2 rows in set (0.00 sec)
  9. obclient> select * from ordr where rownum<3\G
  10. *************************** 1. row ***************************
  11. O_W_ID: 2
  12. O_D_ID: 1
  13. O_ID: 2100
  14. O_C_ID: 2360
  15. O_CARRIER_ID: 10
  16. O_OL_CNT: 8
  17. O_ALL_LOCAL: 1
  18. O_ENTRY_D: 2020-02-15 18:58:22
  19. *************************** 2. row ***************************
  20. O_W_ID: 2
  21. O_D_ID: 1
  22. O_ID: 2101
  23. O_C_ID: 2101
  24. O_CARRIER_ID: NULL
  25. O_OL_CNT: 14
  26. O_ALL_LOCAL: 1
  27. O_ENTRY_D: 2020-02-15 18:58:22
  28. 2 rows in set (0.00 sec)