MapR DB CLI Tutorial

Blog Post created by vgutta on Jan 25, 2017


MapR CLI has a large number of options, organized into subcommands. By typing "maprcli" without any options, you will get a usage summary showing all the subcommands. Use that to remind yourself of the subcommands and options.

The MapR CLI commands use the following conventions:

  • [Square brackets] indicate an optional parameter
  • <Angle brackets> indicate a value to enter

These tools are incredibly useful for administrators who operate the Hadoop cluster, as well as for developers trying to debug Hadoop applications.


The objective of this blog is to get you started with the administration operations using command line interface for MapR-DB tables.

This section assumes that you performed the following task:

MapR-DB supports two types of table: binary tables and JSON tables. This section covers how to create, edit, and delete tables, as well as how to set parameter values, display parameter values, and grant permissions and access.

For a conceptual overview of binary tables, see Introduction to Binary Tables.

For a conceptual overview of JSON tables, which contain OJAI documents, see JSON Tables.

Administering Tables


Creating Tables

There are several methods that you can use to create MapR-DB tables.

Methods Common to Both Table Types

There are two methods that you can use to create both binary tables and JSON tables:

maprcli command

MCS (will not be covered in this document)


Method for Binary Tables Only

hbase Shell


Method for JSON Tables Only

mapr dbshell


Using maprcli command

The basic command to create a binary table is:

maprcli table create -path <path>

To create a JSON table, include the -tabletype parameter and set it to json:

maprcli table create -path <path> -tabletype json

The -tabletype parameter is set to binary by default.

Note: The format of the value of the -path parameter depends on whether you are creating a table on a local cluster or a remote cluster:

For a path on the local cluster, start the path at the volume mount point. For example, for a table named "testunder a volume with a mount point at /volume1," specify the following path: /volume1/test

For a path on a remote cluster, you must also specify the cluster name in the path. For example, for a table named "customer under volume1 in the sanfrancisco cluster," specify the following: path:/mapr/sanfrancisco/volume1/customer

Throughout this document, the path is assumed to be on a local cluster. Ex: /user/user01/tables

Login in to MapR host using a terminal by user user01.


To create a binary table
maprcli table create -path /user/user01/tables/customer_binary

Add a column family with the maprcli table cf create command. For details see table cf create or type "maprcli table cf create -help" at a command line. The following example demonstrates addition of a column family named "addr" in table /user/user01/tables/customer_binary, using lz4 compression, and keeping a maximum of 5 versions of cells in the column family:

maprcli table cf create -path /user/user01/tables/customer_binary -cfname addr -compression lzf -maxversions 5

To see the CF properties run the following command:

maprcli table cf list -path /user/user01/tables/customer_binary


readperm  appendperm  inmemory  versionperm  cfname  writeperm  compressionperm  memoryperm  compression  ttl         maxversions  minversions 

u:user01  u:user01    false     u:user01     addr    u:user01   u:user01         u:user01    lzf          2147483647  5            0

To create a JSON table
maprcli table create -path /user/user01/tables/customer_json –tabletype json

Using the mapr dbshell Utility

Assuming you are connected to your MapR host using a terminal, you can run the following command to launch the shell:

$ mapr dbshell

You can list all the commands of the shell by using help. Use the shell as shown in the following examples.

Create a table:

maprdb user01:> create /user/user01/tables/customer_json

If successful, output as below:

Table /user/user01/tables/customer_json created.


Using the hbase sell Utility

Connect to your MapR host using a terminal and run the following command to launch a shell:

$ hbase shell

hbase(main):001:0> create '/user/user01/tables/customer_binary', {NAME=>'addr'}, {NAME=>'order'}

‘addr’ and ‘order’ are column families.

Note: at least one column family needs to specified; the rest of the column families can be added later at any point of time by editing the table.

If successful, output as below:

0 row(s) in 0.2030 seconds

=> Hbase::Table - /user/user01/tables/customer_binary


Displaying Table Information

Use either a maprcli command or MCS to display all of the information that MapR-DB stores about a particular table.

Run the command maprcli table info -path <path> -json. The json parameter displays the output as a JSON document.

maprcli table info -path /user/user01/tables/customer_json –json

The output of the command is as follows:




    "timeofday":"2016-12-05 12:16:18.666 GMT+0000",





































Finding Table Type

In the table info output, look for the line "tabletype":value . Possible values are binary and json.


Finding Permissions that are on a Table

In the table info output, look for the lines in which the quoted string ends in perm.


Editing Tables

Use either the maprcli command table edit or MCS to edit the attributes of a MapR-DB binary or JSON table. You can also use the HBase shell to edit a binary table.

When you edit a table with this command, you can change a number of properties.

Run the command maprcli table edit -path <path>.

   To run this command, your user ID must have the following permissions:

Ex: Change adminaccessperm to the table, the Access Control Expression that controls who can view and edit the permissions for this table. By default, permission is given to the user ID that was used to create the table.


Granting Permissions on Tables

Use the -*perm parameters of the table create or table edit command.

For a list of all of the permissions that you can set on a table, use table create or table edit.

To grant admin permission to user "user02"on a table which was created by "user01":

maprcli table edit -path /user/user01/tables/customer_json  -adminaccessperm u:user02

Dropping Tables

Use either the maprcli command table delete or MCS to drop a MapR-DB table.

Run the command maprcli table delete -path <path> .

maprcli table delete -path /user/user01/tables/customer_json

Check MapR documentation, for more information on Administering MapR-DB tables.


Create, read, update and delete (CRUD) operations


CRUD for Binary Tables

Open hbase shell.

Put some data into the table:

put '/user/user01/customer_binary',  'jsmith',  'addr:city', 'nashville'

put  '/user/user01/customer_binary', 'jsmith',  'addr:state', 'TN'

put  '/user/user01/customer_binary', 'jsmith',  'order:numb', '1234'

put  '/user/user01/customer_binary', 'jsmith',  'order:date', '10-18-2014'

Use ‘get’ to retrieve the data for ‘jsmith’:

get  '/user/user01/customer_binary', 'jsmith'

Retrieve all rows, all columns:

scan '/user/user01/customer_binary'

Delete a column family:

delete  'user/user01/customer_binary',  'jsmith',   'addr:'

Delete a row:

delete  'user/user01/customer_binary',  'jsmith'

Check MapR documentation, for more information on HBase Shell for MapR-DB.


CRUD operation for JSON Tables

Open mapr dbshell.

Add a new document in the table:

insert /user/user01/tables/customer_json  --id "001" --value '{"first_name":"John", "last_name":"Doe", "age" : 34 }'

Get one document by ID:

findbyid /user/user01/tables/customer_json --id 001

Get all documents:

find /user/user01/tables/customer_json

Delete a document:

delete /user/user01/tables/customer_json  --id "001

Check MapR documentation for more information on mapr dbshell.


Related Resources

Visit MapR-DB, MapR Converged Data Platform,  The Exchange


More on mapr-db

Explore MapR-DB Resources & Product Information

Accessing MapR DB without installing MapR Client 

Save MapR Streams messages into MapR DB JSON 

ACE(Access Control Expressions) to specified column in MapR-DB