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

示例

  • 通过 obclient 查看 MySQL 租户的数据库对象。
  1. #obclient -h192.168.1.101 -utpcc@obmysql#obdemo -P2883 -p123456 -A tpccdb
  2. obclient> show tables;
  3. +------------------+
  4. | Tables_in_tpccdb |
  5. +------------------+
  6. | cust |
  7. | dist |
  8. | hist |
  9. | item |
  10. | load_hist |
  11. | load_proc |
  12. | nord |
  13. | ordl |
  14. | ordr |
  15. | stock_item |
  16. | stok |
  17. | ware |
  18. +------------------+
  19. 12 rows in set (0.01 sec)
  • 通过 obclient 查看 MySQL 租户的表属性
  1. obclient> desc ordl;
  2. +----------------+--------------+------+-----+---------+-------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +----------------+--------------+------+-----+---------+-------+
  5. | ol_w_id | int(11) | NO | PRI | NULL | |
  6. | ol_d_id | int(11) | NO | PRI | NULL | |
  7. | ol_o_id | int(11) | NO | PRI | NULL | |
  8. | ol_number | int(11) | NO | PRI | NULL | |
  9. | ol_delivery_d | date | YES | | NULL | |
  10. | ol_amount | decimal(6,2) | YES | | NULL | |
  11. | ol_i_id | int(11) | YES | | NULL | |
  12. | ol_supply_w_id | int(11) | YES | | NULL | |
  13. | ol_quantity | int(11) | YES | | NULL | |
  14. | ol_dist_info | char(24) | YES | | NULL | |
  15. +----------------+--------------+------+-----+---------+-------+
  16. 10 rows in set (0.01 sec)
  17. obclient> show create table ordl\G
  18. *************************** 1. row ***************************
  19. Table: ordl
  20. Create Table: CREATE TABLE `ordl` (
  21. `ol_w_id` int(11) NOT NULL,
  22. `ol_d_id` int(11) NOT NULL,
  23. `ol_o_id` int(11) NOT NULL,
  24. `ol_number` int(11) NOT NULL,
  25. `ol_delivery_d` date DEFAULT NULL,
  26. `ol_amount` decimal(6,2) DEFAULT NULL,
  27. `ol_i_id` int(11) DEFAULT NULL,
  28. `ol_supply_w_id` int(11) DEFAULT NULL,
  29. `ol_quantity` int(11) DEFAULT NULL,
  30. `ol_dist_info` char(24) DEFAULT NULL,
  31. PRIMARY KEY (`ol_w_id`, `ol_d_id`, `ol_o_id`, `ol_number`)
  32. ) 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'
  33. partition by hash(ol_w_id) partitions 6
  34. 1 row in set (0.02 sec)
  • 通过 obclient 查看 MySQL 租户的表数据
  1. obclient> select * from ware;
  2. +------+---------+--------+------------+---------------------+----------------------+--------------+---------+-----------+
  3. | w_id | w_ytd | w_tax | w_name | w_street_1 | w_street_2 | w_city | w_state | w_zip |
  4. +------+---------+--------+------------+---------------------+----------------------+--------------+---------+-----------+
  5. | 1 | 1200.00 | 0.1868 | n1P4zYo8OH | jTNkXKWXOdh | lf9QXTXXGoF04IZBkCP7 | srRq15uvxe5 | GQ | 506811111 |
  6. | 2 | 1200.00 | 0.0862 | L6xwRsbDk | xEdT1jkENtbLwoI1Zb0 | NT0j4RCQ4OqrS | vlwzndw2FPrO | XR | 063311111 |
  7. +------+---------+--------+------------+---------------------+----------------------+--------------+---------+-----------+
  8. 2 rows in set (0.01 sec)

也可以使用参数’\G’结尾按列展示每行数据

  1. obclient> select * from ware\G
  2. *************************** 1. row ***************************
  3. w_id: 1
  4. w_ytd: 1200.00
  5. w_tax: 0.1868
  6. w_name: n1P4zYo8OH
  7. w_street_1: jTNkXKWXOdh
  8. w_street_2: lf9QXTXXGoF04IZBkCP7
  9. w_city: srRq15uvxe5
  10. w_state: GQ
  11. w_zip: 506811111
  12. *************************** 2. row ***************************
  13. w_id: 2
  14. w_ytd: 1200.00
  15. w_tax: 0.0862
  16. w_name: L6xwRsbDk
  17. w_street_1: xEdT1jkENtbLwoI1Zb0
  18. w_street_2: NT0j4RCQ4OqrS
  19. w_city: vlwzndw2FPrO
  20. w_state: XR
  21. w_zip: 063311111
  22. 2 rows in set (0.01 sec)
  23. obclient>