在 obclient 命令行环境里,可以通过一些命令或者 SQL 查看数据库对象或者表属性和数据。
示例
- 通过 obclient 查看 MySQL 租户的数据库对象。
#obclient -h192.168.1.101 -utpcc@obmysql#obdemo -P2883 -p123456 -A tpccdb
obclient> show tables;
+------------------+
| Tables_in_tpccdb |
+------------------+
| cust |
| dist |
| hist |
| item |
| load_hist |
| load_proc |
| nord |
| ordl |
| ordr |
| stock_item |
| stok |
| ware |
+------------------+
12 rows in set (0.01 sec)
- 通过 obclient 查看 MySQL 租户的表属性
obclient> desc ordl;
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| ol_w_id | int(11) | NO | PRI | NULL | |
| ol_d_id | int(11) | NO | PRI | NULL | |
| ol_o_id | int(11) | NO | PRI | NULL | |
| ol_number | int(11) | NO | PRI | NULL | |
| ol_delivery_d | date | YES | | NULL | |
| ol_amount | decimal(6,2) | YES | | NULL | |
| ol_i_id | int(11) | YES | | NULL | |
| ol_supply_w_id | int(11) | YES | | NULL | |
| ol_quantity | int(11) | YES | | NULL | |
| ol_dist_info | char(24) | YES | | NULL | |
+----------------+--------------+------+-----+---------+-------+
10 rows in set (0.01 sec)
obclient> show create table ordl\G
*************************** 1. row ***************************
Table: ordl
Create Table: CREATE TABLE `ordl` (
`ol_w_id` int(11) NOT NULL,
`ol_d_id` int(11) NOT NULL,
`ol_o_id` int(11) NOT NULL,
`ol_number` int(11) NOT NULL,
`ol_delivery_d` date DEFAULT NULL,
`ol_amount` decimal(6,2) DEFAULT NULL,
`ol_i_id` int(11) DEFAULT NULL,
`ol_supply_w_id` int(11) DEFAULT NULL,
`ol_quantity` int(11) DEFAULT NULL,
`ol_dist_info` char(24) DEFAULT NULL,
PRIMARY KEY (`ol_w_id`, `ol_d_id`, `ol_o_id`, `ol_number`)
) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.0' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 10 TABLEGROUP = 'tpcc_group'
partition by hash(ol_w_id) partitions 6
1 row in set (0.02 sec)
- 通过 obclient 查看 MySQL 租户的表数据
obclient> select * from ware;
+------+---------+--------+------------+---------------------+----------------------+--------------+---------+-----------+
| w_id | w_ytd | w_tax | w_name | w_street_1 | w_street_2 | w_city | w_state | w_zip |
+------+---------+--------+------------+---------------------+----------------------+--------------+---------+-----------+
| 1 | 1200.00 | 0.1868 | n1P4zYo8OH | jTNkXKWXOdh | lf9QXTXXGoF04IZBkCP7 | srRq15uvxe5 | GQ | 506811111 |
| 2 | 1200.00 | 0.0862 | L6xwRsbDk | xEdT1jkENtbLwoI1Zb0 | NT0j4RCQ4OqrS | vlwzndw2FPrO | XR | 063311111 |
+------+---------+--------+------------+---------------------+----------------------+--------------+---------+-----------+
2 rows in set (0.01 sec)
也可以使用参数’\G’结尾按列展示每行数据
obclient> select * from ware\G
*************************** 1. row ***************************
w_id: 1
w_ytd: 1200.00
w_tax: 0.1868
w_name: n1P4zYo8OH
w_street_1: jTNkXKWXOdh
w_street_2: lf9QXTXXGoF04IZBkCP7
w_city: srRq15uvxe5
w_state: GQ
w_zip: 506811111
*************************** 2. row ***************************
w_id: 2
w_ytd: 1200.00
w_tax: 0.0862
w_name: L6xwRsbDk
w_street_1: xEdT1jkENtbLwoI1Zb0
w_street_2: NT0j4RCQ4OqrS
w_city: vlwzndw2FPrO
w_state: XR
w_zip: 063311111
2 rows in set (0.01 sec)
obclient>