command line connection
./sqlline.py localhost:2181
create schema
create schema IF NOT EXISTS "test";
The following error may be reported for the first creation, and the configuration file needs to be modified
Error: ERROR 725 (43M08): Cannot create schema because config phoenix.schema.isNamespaceMappingEnabled for enabling name space mapping isn't enabled. schemaName="test" (state=43M08,code=725)
java.sql.SQLException: ERROR 725 (43M08): Cannot create schema because config phoenix.schema.isNamespaceMappingEnabled for enabling name space mapping isn't enabled. schemaName="test"
Modify the $HASE_HOME/conf/hbase-site.xml file and the $PHOENIX_HOME/bin/hbase-site.xml file, and restart the Hbase service after the modification
<property>
<name>phoenix.schema.isNamespaceMappingEnabled</name>
<value>true</value>
</property>
<property>
<name>phoenix.schema.mapSystemTablesToNamespace</name>
<value>true</value>
</property>
switch schema
use "test";
create table
CREATE TABLE IF NOT EXISTS user(id VARCHAR NOT NULL primary key, name VARCHAR,age VARCHAR,date Date);
View table structure
!tables
!desc user;
Add and modify
upsert into USER (id,name,age,date) values('1','zhangsan','18','2023-7-18');
view data
delete data
delete from USER where id = '1';
delete all
delete from USER;
upsert into USER (id,name,age,date) values('1','zhangsan','18','2023-7-18');
upsert into USER (id,name,age,date) values('2','lisi','20','2023-7-18');
select * from USER;
upsert into USER (id,name,age,date) values('2','lisi2','20','2023-7-18');
select * from USER;
Commonly used field types for table creation
create table test01 (
col1 integer not null primary key,
col2 varchar(2),
col3 varchar(5),
col4 decimal(4,2),
col5 decimal(6,3)
);