Phoenix命令行连接,增删改查常用基本操作

命令行连接

./sqlline.py localhost:2181

Phoenix命令行连接,增删改查常用基本操作_第1张图片

 

创建schema

create schema IF NOT EXISTS "test";

第一次创建有可能会报如下错误,需要修改配置文件

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"

Phoenix命令行连接,增删改查常用基本操作_第2张图片

修改$HASE_HOME/conf/hbase-site.xml文件和 $PHOENIX_HOME/bin/hbase-site.xml文件,修改完成重启Hbase服务

  phoenix.schema.isNamespaceMappingEnabled

  true

  phoenix.schema.mapSystemTablesToNamespace

  true

切换schema

use "test";

创建表

CREATE TABLE IF NOT EXISTS user(id VARCHAR NOT NULL primary key, name VARCHAR,age VARCHAR,date Date);

查看表结构

!tables

!desc user;

添加和修改

upsert into USER (id,name,age,date) values('1','zhangsan','18','2023-7-18');

查看数据

删除数据

delete from USER where id = '1';

删除所有

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;

Phoenix命令行连接,增删改查常用基本操作_第3张图片

常用建表字段类型

create table test01 (
col1 integer not null primary key,
col2 varchar(2),
col3 varchar(5),
col4 decimal(4,2),
col5 decimal(6,3)
);

你可能感兴趣的:(大数据,sql,数据库,mysql)