We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
GuidesApplication FrameworkArkDataArkData Debugging Toolvector-store Database Debugging Tool Guide

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.

NOTE

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

Environment requirements

  • Before using this tool, you need to obtain the HDC tool, enable the Developer Options, and run the hdc shell command.
  • This debugging tool can be used only for debugging applications. For details about how to configure a debugged application, see Running/Debugging Configuration.
  • Connect the devices properly.

Preparations

  • Before using the vector-store debugging tool, switch to the target application path and then run the arkdata command to access the vector-store debugging tool. (You need to use ArkData to configure relevant parameters to open the vector-store database, and only after the database is successfully opened can you use the vector-store tool to add, delete, modify, and query data.)

    The following table describes the parameters supported by the arkdata command.

    Expand
    Parameter Value Type Description
    -t String Database type, which is used to access the corresponding database debugging tool. Value range: {preference_kv, preference_xml, vector}
    -f String Full path of the database file, which includes the file name. The path cannot end with a slash (/).
    -h N/A Help information about the program.
    NOTE

    For the vector-store database debugging tool, the -p and -c parameters are not involved.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. C:\Users\*****>hdc shell
    2. $ cd /data/app/el1/100/base/com.test.myapplication // Go to the target app path. (The current path is an example. Go to the path based on your actual needs.)
    3. $ arkdata -t vector // -f is not specified, indicating that no database file is specified. By default, a database named arkdata is created in the data/vector directory of the current working directory.
    4. Enter ".help" for usage hints.
    5. vector>>> .q

    When opening the database in the path of a non-target application, if the -f parameter is missing (which would trigger the default folder creation), the process of creating the data/vector folder hierarchy in the current directory fails. The error information is as follows:

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. C:\Users\*****>hdc shell
    2. $ arkdata -t vector
    3. [unsucc]Failed to create directory ./data/vector : Permission denied

    When opening the database in the path of a non-target application, the .db file fails to be created in the specified path. The error information is as follows:

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. C:\Users\*****>hdc shell
    2. $ arkdata -t vector -f ./vector
    3. [GMDB SERVER] [GMERR-1013000] multi-process init init unsucc!
    4. [ERROR] open db fail, ret = -5000.
  • Run the arkdata --help command to view the parameters related to the entire graph store.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. C:\Users\*****>hdc shell
    2. $ arkdata --help
    3. USAGE
    4. arkdata [option]
    5. OPTION
    6. -t|--type <preference_kv | preference_xml | vector>, it is mandatory
    7. -f|--file <database file path>
    8. -p|--pageSize <database pageSize>
    9. -c|--cacheSize <database cacheSize>
    10. -h|--help

Command Reference

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

Expand
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.

Expand
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

  • For the vector-store database debugging tool, the maximum length of a command statement is 1024 × 1024-1.

  • Since hdc displays garbled characters when Chinese is used, the database debugging tool does not support Chinese.

  • Mobile phones and PCs/2-in-1 devices are supported.

Command Usage and Examples

Help Command (.help)

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

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> .help

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.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. C:\Users\*****>hdc shell
    2. $ 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.)
    3. $ 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.
    4. $ arkdata -t vector
    5. Enter ".help" for usage hints.
    6. 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.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. $ ls -lZ ./data/vector/
    2. total 176
    3. -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0 77824 2025-08-12 20:12 arkdata
    4. -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0 8208 2025-08-12 20:13 arkdata.ctrl
    5. -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0 24592 2025-08-12 20:13 arkdata.ctrl.dwr
    6. -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0 512 2025-08-12 20:13 arkdata.redo
    7. -rw------- 1 shell shell u:object_r:debug_hap_data_file:s0 8 2025-08-12 20:13 arkdata.safe
    8. -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.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. $ arkdata -t vector -f ./data/vector/arkdata
    2. Enter ".help" for usage hints.
    3. vector>>>

Creating a Table

  • At the vector>>> prompt, run the create table command to create a table.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. // Create a table via a single-line command.
    2. vector>>> create table t1(a int unique, b text);
    3. vector>>> .schema
    4. +-------+------+----------+----------------------------------------+
    5. | type | name | tbl_name | sql |
    6. +-------+------+----------+----------------------------------------+
    7. | TABLE | T1 | T1 | create table t1(a int unique, b text); |
    8. +-------+------+----------+----------------------------------------+
    9. // Create a table via a single multi-line command.
    10. vector>>> create table t7(
    11. a int unique,
    12. b text);
    13. vector>>> .schema
    14. +-------+------+----------+---------------------------------------+
    15. | type | name | tbl_name | sql |
    16. +-------+------+----------+---------------------------------------+
    17. | TABLE | t7 | t7 | create table t7(a int unique,b text); |
    18. +-------+------+----------+---------------------------------------+
  • At the vector>>> prompt, run the following commands to create multiple tables.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. // Create tables via multiple commands in a single line.
    2. vector>>> create table t7(a int unique, b text); create table t8(a int unique, b text);
    3. vector>>> .schema
    4. +-------+------+----------+-----------------------------------------+
    5. | type | name | tbl_name | sql |
    6. +-------+------+----------+-----------------------------------------+
    7. | TABLE | t7 | t7 | create table t7(a int unique, b text); |
    8. | TABLE | t8 | t8 | create table t8(a int unique, b text); |
    9. +-------+------+----------+-----------------------------------------+
    10. // Create tables via multiple commands in multiple lines.
    11. vector>>> create table t7(
    12. a int unique,
    13. b text);
    14. create table t8(
    15. a int unique,
    16. b text);
    17. vector>>> .schema
    18. +-------+------+----------+---------------------------------------+
    19. | type | name | tbl_name | sql |
    20. +-------+------+----------+---------------------------------------+
    21. | TABLE | t7 | t7 | create table t7(a int unique,b text); |
    22. | TABLE | t8 | t8 | create table t8(a int unique,b text); |
    23. +-------+------+----------+---------------------------------------+

Querying a Table

  • At the vector>>> prompt, run the .table command to list all table names in the database. The following information is displayed.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. vector>>>.table
    2. +------+
    3. | name |
    4. +------+
    5. | T1 |
    6. | T2 |
    7. | T3 |
    8. +------+
  • Run the .schema command to display the structure information of all tables in the database. The following information is displayed.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. vector>>>.schema
    2. +-------+-------+----------+----------------------------------------+
    3. | type | name | tbl_name | sql |
    4. +-------+-------+----------+----------------------------------------+
    5. | TABLE | T1 | T1 | create table t1(a int unique, b text); |
    6. | TABLE | T2 | T2 | create table t2(a int unique, b text); |
    7. | TABLE | T3 | T3 | create table t3(a int, b text); |
    8. | TABLE | t7 | t7 | create table t7(a int unique,b text); |
    9. | TABLE | t8 | t8 | create table t8(a int unique,b text); |
    10. Press 'q' to quit, 'n' to continue: i
    11. Invalid input. Press 'q' to quit, 'n' to continue: n
    12. | TABLE | T9 | T9 | create table t9(a int unique,b text); |
    13. +-------+-------+----------+----------------------------------------+
    NOTE

    When the number of displayed data items reaches 5, the system asks you whether to continue displaying or exit. Enter q to exit the display or enter n to continue displaying.

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> .schema
  2. +-------+------+----------+--------------------------------------+
  3. | type | name | tbl_name | sql |
  4. +-------+------+----------+--------------------------------------+
  5. | TABLE | T1 | T1 | create table t1( a int, new_b text); |
  6. +-------+------+----------+--------------------------------------+
  7. vector>>> alter table t1 rename to new_t1; // Rename t1 to new_t1.
  8. vector>>> .schema
  9. +-------+--------+----------+------------------------------------------+
  10. | type | name | tbl_name | sql |
  11. +-------+--------+----------+------------------------------------------+
  12. | TABLE | NEW_T1 | NEW_T1 | create table NEW_T1( a int, new_b text); |
  13. +-------+--------+----------+------------------------------------------+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> create table t1( a int, b text);
  2. vector>>> .schema
  3. +-------+------+----------+----------------------------------+
  4. | type | name | tbl_name | sql |
  5. +-------+------+----------+----------------------------------+
  6. | TABLE | T1 | T1 | create table t1( a int, b text); |
  7. +-------+------+----------+----------------------------------+
  8. vector>>> alter table t1 add column c text; // Add a field named c of the text type to the table t1.
  9. vector>>> .schema
  10. +-------+------+----------+------------------------------------------+
  11. | type | name | tbl_name | sql |
  12. +-------+------+----------+------------------------------------------+
  13. | TABLE | T1 | T1 | create table t1( a int, b text, c text); |
  14. +-------+------+----------+------------------------------------------+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> .schema
  2. +-------+------+----------+----------------------------------+
  3. | type | name | tbl_name | sql |
  4. +-------+------+----------+----------------------------------+
  5. | TABLE | T1 | T1 | create table t1( a int, b text); |
  6. +-------+------+----------+----------------------------------+
  7. vector>>> alter table t1 rename b to new_b; // Rename column b of table t1 to new_b.
  8. vector>>> .schema
  9. +-------+------+----------+--------------------------------------+
  10. | type | name | tbl_name | sql |
  11. +-------+------+----------+--------------------------------------+
  12. | TABLE | T1 | T1 | create table t1( a int, new_b text); |
  13. +-------+------+----------+--------------------------------------+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> .schema
  2. +-------+------+----------+------------------------------------------+
  3. | type | name | tbl_name | sql |
  4. +-------+------+----------+------------------------------------------+
  5. | TABLE | T1 | T1 | create table t1( a int, b text, c text); |
  6. +-------+------+----------+------------------------------------------+
  7. vector>>> alter table t1 drop column c; // Delete the c field from the t1 table.
  8. vector>>> .schema
  9. +-------+------+----------+----------------------------------+
  10. | type | name | tbl_name | sql |
  11. +-------+------+----------+----------------------------------+
  12. | TABLE | T1 | T1 | create table t1( a int, b text); |
  13. +-------+------+----------+----------------------------------+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>>drop table t1; // Delete table t1.
  2. vector>>>.table
  3. +------+
  4. | name |
  5. +------+
  6. | T2 |
  7. +------+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> create table t3(a int, b text); // An index can be created only when no data is added to the table.
  2. vector>>> create index idx_1 on t3(a); // Add an index idx_1 to the corresponding column of the table.
  3. vector>>> .index
  4. +-------+
  5. | name |
  6. +-------+
  7. | idx_1 |
  8. +-------+

Inserting Data

  • At the vector>>> prompt, run the insert into t2 values(1,'xx'),(2,'yy'); command to insert the specified KV pair. The following information is displayed.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. vector>>> insert into t2 values(1,'xx'),(2,'yy');
    2. vector>>> select * from t2;
    3. +----+----+
    4. | a | b |
    5. +----+----+
    6. | 1 | xx |
    7. | 2 | yy |
    8. +----+----+
    9. vector>>> create table t1(a int unique, b text);
    10. vector>>> insert into t1 values(1,'x'),(2,'y');
    11. vector>>> select * from t1;
    12. +----+----+
    13. | a | b |
    14. +----+----+
    15. | 1 | x |
    16. | 2 | y |
    17. +----+----+
  • At the vector>>> prompt, run the following commands to insert multiple data records.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. // Insert multiple data records via a single multi-line command.
    2. vector>>> insert into t7 values(1,'x'),
    3. (2,'y');
    4. vector>>> select * from t7;
    5. +----+---+
    6. | a | b |
    7. +----+---+
    8. | 1 | x |
    9. | 2 | y |
    10. +----+---+
    11. // Insert multiple data records via multiple commands in a single line.
    12. vector>>> insert into t7 values(1,'x');insert into t7 values(2,'y');
    13. vector>>> select * from t7;
    14. +----+---+
    15. | a | b |
    16. +----+---+
    17. | 1 | x |
    18. | 2 | y |
    19. +----+---+
    20. // Insert multiple data records via multiple commands in multiple lines.
    21. vector>>> insert into t7 values(1,'x'),
    22. (2,'y');
    23. insert into t8 values(1,'xx'),
    24. (2,'yy');
    25. vector>>> select * from t7;
    26. +----+---+
    27. | a | b |
    28. +----+---+
    29. | 1 | x |
    30. | 2 | y |
    31. +----+---+
    32. vector>>> select * from t8;
    33. +----+----+
    34. | a | b |
    35. +----+----+
    36. | 1 | xx |
    37. | 2 | yy |
    38. +----+----+

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.

      Collapse
      Word wrap
      Dark theme
      Copy code
      1. vector>>> .mode print
      2. vector>>> select * from t1;
      3. [row-0]
      4. a = 1
      5. b = x
      6. [row-1]
      7. a = 2
      8. 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.

      Collapse
      Word wrap
      Dark theme
      Copy code
      1. vector>>> .mode table
      2. vector>>> select * from t1;
      3. +----+---+
      4. | a | b |
      5. +----+---+
      6. | 1 | x |
      7. | 2 | y |
      8. +----+---+
  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.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. vector>>> select * from t1 where a =1;
    2. +----+---+
    3. | a | b |
    4. +----+---+
    5. | 1 | x |
    6. +----+---+
  3. At the vector>>> prompt, run the .count command to list the total number of records in all tables. The following information is displayed.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. vector>>> .count
    2. +------------+--------------+
    3. | table_name | record_count |
    4. +------------+--------------+
    5. | T1 | 2 |
    6. | T2 | 2 |
    7. | T3 | 0 |
    8. +------------+--------------+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> select * from t1;
  2. +----+----+
  3. | a | b |
  4. +----+----+
  5. | 1 | x |
  6. | 2 | y |
  7. | 3 | xx |
  8. +----+----+
  9. vector>>> update t1 set b = 'z' where a =3;
  10. vector>>> select * from t1;
  11. +----+---+
  12. | a | b |
  13. +----+---+
  14. | 1 | x |
  15. | 2 | y |
  16. | 3 | z |
  17. +----+---+

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.

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>> select * from t1;
  2. +----+---+
  3. | a | b |
  4. +----+---+
  5. | 1 | x |
  6. | 2 | y |
  7. | 3 | z |
  8. +----+---+
  9. vector>>> delete from t1 where b = 'z';// Delete z from the t1 table.
  10. vector>>> select * from t1;
  11. +----+---+
  12. | a | b |
  13. +----+---+
  14. | 1 | x |
  15. | 2 | y |
  16. +----+---+

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

Collapse
Word wrap
Dark theme
Copy code
  1. vector>>>.q
  2. $

Emulator Support

This tool supports the Emulator.

FAQs

How do I delete characters?

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