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
- Go to the /home directory.
cd /home
- Create a database directory.
mkdir –p /home/rocksdb/rkdb
- 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.
- Use ldb to run the put command to add data.
ldb --db=/home/rocksdb/rkdb put k2 v2

- 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

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

Parent topic: Examples