Rate This Document
Findability
Accuracy
Completeness
Readability

Commands put and batchput

Prerequisites

Before running following commands, create a target database or ensure that a database has been created. For details about how to create a database, see 2.

Procedure

  1. Go to the /home directory.
    cd /home
  2. Create a database directory.
    mkdir –p /home/rocksdb/rkdb
  3. Use ldb to create a database and run the put command to write the first piece of data.
    ldb  --db=/home/rocksdb/rkdb --create_if_missing put k1 v1

    If the target database to be operated by ldb does not exist and the error message "does not exist" is displayed, add the --create_if_missing parameter to create one.

  4. Use ldb to run the put command to add data.
    ldb  --db=/home/rocksdb/rkdb put k2 v2

  5. Use ldb to run the batchput command to write data in a batch.
    ldb  --db=/home/rocksdb/rkdb batchput k3 v3 k4 v4 k5 555 kstring abcd

  6. Run the scan command to view the data written to the database.
    ldb  --db=/home/rocksdb/rkdb scan