在 obclient 命令行环境里,可以通过一些命令或者 SQL 查看数据库对象或者表属性和数据。
示例
- 通过 obclient 查看 Oracle 租户下 TPCC 模式下的数据库对象。
$obclient -h192.168.1.101 -utpcc@t_oracle0_91#obdoc -P2883 -p123456 tpcc
obclient> select object_type,count(*) from user_objects group by object_type;
+-----------------+----------+
| OBJECT_TYPE | COUNT(*) |
+-----------------+----------+
| TABLE | 15 |
| INDEX | 2 |
| VIEW | 1 |
| TABLE PARTITION | 48 |
| PROCEDURE | 5 |
+-----------------+----------+
5 rows in set (0.01 sec)
- 通过 obclient 查看 TPCC 模式下的表属性
obclient> desc ordl;
+----------------+-------------+------+-----+---------+-------+
| FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA |
+----------------+-------------+------+-----+---------+-------+
| OL_W_ID | NUMBER(38) | NO | PRI | NULL | NULL |
| OL_D_ID | NUMBER(38) | NO | PRI | NULL | NULL |
| OL_O_ID | NUMBER(38) | NO | PRI | NULL | NULL |
| OL_NUMBER | NUMBER(38) | NO | PRI | NULL | NULL |
| OL_DELIVERY_D | DATE | YES | NULL | NULL | NULL |
| OL_AMOUNT | NUMBER(6,2) | YES | NULL | NULL | NULL |
| OL_I_ID | NUMBER(38) | YES | NULL | NULL | NULL |
| OL_SUPPLY_W_ID | NUMBER(38) | YES | NULL | NULL | NULL |
| OL_QUANTITY | NUMBER(38) | YES | NULL | NULL | NULL |
| OL_DIST_INFO | CHAR(24) | YES | NULL | NULL | NULL |
+----------------+-------------+------+-----+---------+-------+
10 rows in set (0.00 sec)
obclient> show create table ordl\G
*************************** 1. row ***************************
TABLE: ORDL
CREATE TABLE: CREATE TABLE "ORDL" (
"OL_W_ID" NUMBER(38) NOT NULL,
"OL_D_ID" NUMBER(38) NOT NULL,
"OL_O_ID" NUMBER(38) NOT NULL,
"OL_NUMBER" NUMBER(38) NOT NULL,
"OL_DELIVERY_D" DATE,
"OL_AMOUNT" NUMBER(6,2),
"OL_I_ID" NUMBER(38),
"OL_SUPPLY_W_ID" NUMBER(38),
"OL_QUANTITY" NUMBER(38),
"OL_DIST_INFO" CHAR(24),
CONSTRAINT "ORDL_OBPK_1581557270705134" PRIMARY KEY ("OL_W_ID", "OL_D_ID", "OL_O_ID", "OL_NUMBER")
) COMPRESS FOR QUERY REPLICA_NUM = 3 BLOCK_SIZE = 16 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 TABLEGROUP = 'TPCC_GROUP'
partition by hash(ol_w_id) partitions 6
1 row in set (0.00 sec)
obclient> show create tablegroup TPCC_GROUP\G
*************************** 1. row ***************************
TABLEGROUP: TPCC_GROUP
CREATE TABLEGROUP: CREATE TABLEGROUP "TPCC_GROUP" BINDING = FALSE
partition by hash partitions 6
1 row in set (0.00 sec)
obclient>
- 通过 obclient 查看 TPCC 模式下的表数据
obclient> select * from ordr where rownum<3;
+--------+--------+------+--------+--------------+----------+-------------+-----------+
| O_W_ID | O_D_ID | O_ID | O_C_ID | O_CARRIER_ID | O_OL_CNT | O_ALL_LOCAL | O_ENTRY_D |
+--------+--------+------+--------+--------------+----------+-------------+-----------+
| 2 | 1 | 2100 | 2360 | 10 | 8 | 1 | 15-FEB-20 |
| 2 | 1 | 2101 | 2101 | NULL | 14 | 1 | 15-FEB-20 |
+--------+--------+------+--------+--------------+----------+-------------+-----------+
2 rows in set (0.00 sec)
obclient> select * from ordr where rownum<3\G
*************************** 1. row ***************************
O_W_ID: 2
O_D_ID: 1
O_ID: 2100
O_C_ID: 2360
O_CARRIER_ID: 10
O_OL_CNT: 8
O_ALL_LOCAL: 1
O_ENTRY_D: 2020-02-15 18:58:22
*************************** 2. row ***************************
O_W_ID: 2
O_D_ID: 1
O_ID: 2101
O_C_ID: 2101
O_CARRIER_ID: NULL
O_OL_CNT: 14
O_ALL_LOCAL: 1
O_ENTRY_D: 2020-02-15 18:58:22
2 rows in set (0.00 sec)