目录

vector-store Database Debugging Tool Guide

Currently, when using the vector-store database for development, debugging, and problem locating, developers are unable to view the content information in the database files, such as metadata and user data.

To improve developers' work efficiency, the database debugging tool allows developers to view the vector-store database on devices.

The vector-store database debugging tool is available since HarmonyOS 6.0.0.

Environment requirements

Preparations

Command Reference

The following table lists the commands supported by the vector-store debugging tool.

Command Format Description
.help Displays the help information.
.q | .quit Exits the database interaction mode.
.mode <table|print> Sets the output format. The default value is table.
.table Lists all table names.
.index Lists all index names.
.schema Lists the schemas of tables.
.count Lists the total number of records in all tables.

The following table lists the common operation cases of the vector-store debugging tool.

Shortcut Command
Creating a Table create table
Querying a Table .table or .schema
Renaming a Table alter table t1 rename to new_t1;
Adding a Table Field alter table t1 add column c text;
Renaming a Table Field alter table t1 rename b to new_b;
Deleting a Table Field alter table t1 drop column c;
Deleting a Table drop table t1;
Adding a Table Index create index idx_1 on t3(a);
Inserting Data insert into t2 values(1,'xx'),(2,'yy');
Querying Data select * from t1;
Updating Data update t1 set b = 'z' where a =3;
Deleting Data delete from t1 where b = 'z';

Constraints

Command Usage and Examples

[h2]Help Command (.help)

After the vector-store database is opened, you can run the help command to view the supported commands.

vector>>> .help

[h2]Creating or Opening an Existing Graph Store

  1. Run the hdc shell command to enter the shell interaction mode.

  2. You must switch to the target application path, go to the path where the db file exists, and run the arkdata -t vector command to create a database.

    C:\Users\*****>hdc shell
    $ cd /data/app/el1/100/database/com.test.myapplication   // Go to the target application path. (The current path is an example. Go to the path based on your actual needs.)
    $ cd entry/rdb/                                          // Go to the path where the .db file exists. You need to have the read and write permissions on the .db file to create a new database.
    $ arkdata -t vector
    Enter ".help" for usage hints.
    vector>>>
  3. Wait for the system to automatically generate the following files. The tag debug_hap_data_file indicates that the file is the target app file.

    $ ls -lZ ./data/vector/
    total 176
    -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0  77824 2025-08-12 20:12 arkdata
    -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0   8208 2025-08-12 20:13 arkdata.ctrl
    -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0  24592 2025-08-12 20:13 arkdata.ctrl.dwr
    -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0    512 2025-08-12 20:13 arkdata.redo
    -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0      8 2025-08-12 20:13 arkdata.safe
    -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0  28672 2025-08-12 20:12 arkdata.undo
  4. Open an existing graph store.

    $ arkdata -t vector -f ./data/vector/arkdata
    Enter ".help" for usage hints.
    vector>>>

[h2]Creating a Table

[h2]Querying a Table

[h2]Renaming a Table

At the vector>>> prompt, run the alter table t1 rename to new_t1; command to rename the table. The following information is displayed.

vector>>> .schema
+-------+------+----------+--------------------------------------+
| type  | name | tbl_name | sql                                  |
+-------+------+----------+--------------------------------------+
| TABLE | T1   | T1       | create table t1( a int, new_b text); |
+-------+------+----------+--------------------------------------+
vector>>> alter table t1 rename to new_t1;  // Rename t1 to new_t1.
vector>>> .schema
+-------+--------+----------+------------------------------------------+
| type  | name   | tbl_name | sql                                      |
+-------+--------+----------+------------------------------------------+
| TABLE | NEW_T1 | NEW_T1   | create table NEW_T1( a int, new_b text); |
+-------+--------+----------+------------------------------------------+

[h2]Adding a Table Field

At the vector>>> prompt, run the alter table t1 add column c text; command to add a table field. The following information is displayed.

vector>>> create table t1( a int, b text);
vector>>> .schema
+-------+------+----------+----------------------------------+
| type  | name | tbl_name | sql                              |
+-------+------+----------+----------------------------------+
| TABLE | T1   | T1       | create table t1( a int, b text); |
+-------+------+----------+----------------------------------+
vector>>> alter table t1 add column c text;  // Add a field named c of the text type to the table t1.
vector>>> .schema
+-------+------+----------+------------------------------------------+
| type  | name | tbl_name | sql                                      |
+-------+------+----------+------------------------------------------+
| TABLE | T1   | T1       | create table t1( a int, b text, c text); |
+-------+------+----------+------------------------------------------+

[h2]Renaming a Table Field

At the vector>>> prompt, run the alter table t1 rename b to new_b; command to rename the table field. The following information is displayed.

vector>>> .schema
+-------+------+----------+----------------------------------+
| type  | name | tbl_name | sql                              |
+-------+------+----------+----------------------------------+
| TABLE | T1   | T1       | create table t1( a int, b text); |
+-------+------+----------+----------------------------------+
vector>>> alter table t1 rename b to new_b; // Rename column b of table t1 to new_b.
vector>>> .schema
+-------+------+----------+--------------------------------------+
| type  | name | tbl_name | sql                                  |
+-------+------+----------+--------------------------------------+
| TABLE | T1   | T1       | create table t1( a int, new_b text); |
+-------+------+----------+--------------------------------------+

[h2]Deleting a Table Field

At the vector>>> prompt, run the alter table t1 drop column c; command to delete the specified field from the table. The following information is displayed.

vector>>> .schema
+-------+------+----------+------------------------------------------+
| type  | name | tbl_name | sql                                      |
+-------+------+----------+------------------------------------------+
| TABLE | T1   | T1       | create table t1( a int, b text, c text); |
+-------+------+----------+------------------------------------------+
vector>>> alter table t1 drop column c;  // Delete the c field from the t1 table.
vector>>> .schema
+-------+------+----------+----------------------------------+
| type  | name | tbl_name | sql                              |
+-------+------+----------+----------------------------------+
| TABLE | T1   | T1       | create table t1( a int, b text); |
+-------+------+----------+----------------------------------+

[h2]Deleting a Table

At the vector>>> prompt, run the drop table t1; command to delete the t1 table from the database. The following information is displayed.

vector>>>drop table t1;  // Delete table t1.
vector>>>.table
+------+
| name |
+------+
| T2   |
+------+

[h2]Adding a Table Index

At the vector>>> prompt, run the create index idx_1 on t3(a); command to add an index to the corresponding column of the table. The following information is displayed.

vector>>> create table t3(a int, b text);  // An index can be created only when no data is added to the table.
vector>>> create index idx_1 on t3(a);     // Add an index idx_1 to the corresponding column of the table.
vector>>> .index
+-------+
| name  |
+-------+
| idx_1 |
+-------+

[h2]Inserting Data

[h2]Querying Data

  1. Scans the full table.

    • At the vector>>> prompt, run the .mode print and select * from table name; commands to query all data in the specified table. The following information is displayed.

      vector>>> .mode print
      vector>>> select * from t1;
      [row-0]
      a            = 1
      b            = x
      [row-1]
      a            = 2
      b            = y
    • At the vector>>> prompt, run the .mode table and select * from table name; commands to query all data in the specified table. The following information is displayed.

      vector>>> .mode table
      vector>>> select * from t1;
      +----+---+
      | a  | b |
      +----+---+
      | 1  | x |
      | 2  | y |
      +----+---+
  2. At the vector>>> prompt, run the select * from table name where filter condition command to query the KV pair of a specified key. The following information is displayed.

    vector>>> select * from t1 where a =1;
    +----+---+
    | a  | b |
    +----+---+
    | 1  | x |
    +----+---+
  3. At the vector>>> prompt, run the .count command to list the total number of records in all tables. The following information is displayed.

    vector>>> .count
    +------------+--------------+
    | table_name | record_count |
    +------------+--------------+
    | T1         | 2            |
    | T2         | 2            |
    | T3         | 0            |
    +------------+--------------+

[h2]Updating Data

At the vector>>> prompt, run the update t1 set b = 'z' where a =3; command to update the KV pair. The following information is displayed.

vector>>> select * from t1;
+----+----+
| a  | b  |
+----+----+
| 1  | x  |
| 2  | y  |
| 3  | xx |
+----+----+
vector>>> update t1 set b = 'z' where a =3;
vector>>> select * from t1;
+----+---+
| a  | b |
+----+---+
| 1  | x |
| 2  | y |
| 3  | z |
+----+---+

[h2]Deleting Data

At the vector>>> prompt, run the delete from t1 where b = 'z'; command to delete the specified KV pair from the table. The following information is displayed.

vector>>> select * from t1;
+----+---+
| a  | b |
+----+---+
| 1  | x |
| 2  | y |
| 3  | z |
+----+---+
vector>>> delete from t1 where b = 'z';// Delete z from the t1 table.
vector>>> select * from t1;
+----+---+
| a  | b |
+----+---+
| 1  | x |
| 2  | y |
+----+---+

At the vector>>> prompt, you can run the .q or .quit command to exit the database interaction mode. The following information is displayed.

vector>>>.q
$

Emulator Support

This tool supports the Emulator.

FAQs

[h2]How do I delete characters?

You can press Ctrl+Backspace to delete a single character and press Ctrl+U to delete all characters.