Write Data to Store

In this section, we will write some sample data to the secure store. To do this, we will create a user and grant the required privileges.

Create a user and grant readwrite privileges to the user. For more details, see User Management and Managing Roles, Privileges and Users.

Open the SQL shell. For more details, see Starting the SQL shell. In the command below, kvroot/security is the security directory. The security directory contains all the security related files that were automatically generated by the securityconfig tool while creating the secure store using the makebootconfig command. For more details, see Configuring security in a data store.
java -Xmx64m -Xms64m -jar lib/sql.jar -helper-hosts phoenix581601:8000 -store mystore
      -security kvroot/security/client.security
Login using the user and password you created in the previous step.
Login as:root
root's password: <password>

Output:

SQL prompt is displayed.
sql->
Create a table and add some data to the table
/*Create a table*/
create table IF NOT EXISTS  ticket (ticketNo LONG,confNo STRING,PRIMARY KEY(ticketNo))
Output:
Statement completed successfully

/*Load data into the table*/
import -table ticket  -file ticket.json
Output:
Loaded 3 rows to ticket.

/*Read data from the table*/
select * from ticket
Output:
{"ticketNo":34567890,"confNo":"DFGRTH"}
{"ticketNo":12345678,"confNo":"LEJDFG"}
{"ticketNo":45367892,"confNo":"FGRTFB"}
3 rows returned