Phoenix Command Line
Phoenix supports SQL statements to operate HBase. The following describes how to use SQL statements to create tables, insert data, query data, and delete tables.
Prerequisites
The HBase client has been installed. For example, the client has been installed in the /opt/client directory. The client directory in the following operations is only an example. Change it based on the actual installation directory onsite. Before using the client, download and update the client configuration file, and ensure that the active management node of Manager is available.
Procedure
- Optional: Log in to the node where the client is installed as the client installation user.
Access the HBase client installation directory:
cd /opt/client
- Run the following command to configure environment variables:
source bigdata_env
- If Kerberos authentication is enabled for the current cluster, run the following command to authenticate the current user. The current user must have the permission to create HBase tables. For details, see Creating a Role to configure roles with required permissions. For details about how to bind roles with users, see Creating a User. If Kerberos authentication is disabled for the current cluster, skip this step:
kinit MRS cluster user
For example, kinit hbaseuser.
- Running Commands on the Phoenix Client.
sqlline.py
- Create a table:
CREATE TABLE TEST (id VARCHAR PRIMARY KEY, name VARCHAR);
- Insert data:
UPSERT INTO TEST(id,name) VALUES ('1','jamee');
- Query data:
SELECT * FROM TEST;
- Deleting a table:
DROP TABLE TEST;
- Exit the Phoenix CLI:
!quit
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.