tencent cloud

游戏数据库 TcaplusDB

产品动态
产品简介
产品概述
产品优势
应用场景
产品架构
地域介绍
购买指南
产品定价
欠费说明
快速入门
了解基本概念
创建集群
创建表格组
创建表格
获取连接信息
访问 TcaplusDB
操作指南
管理集群与表格组
管理表格
监控与告警
访问管理
标签
任务列表
使用 TcaplusDB client
使用 client 工具访问数据
client 工具命令参考
使用 TcaplusDB SDK
变更历史
SDK 下载
SDK for C++ 接口说明
TcaplusDB 错误码
SDK 安装
PB 表 C++SDK 操作方法
TDR 表 C++SDK 操作方法
使用 TcaplusDB RESTful API
RESTful API 接口说明
Go RESTful API 接口说明
Java RESTful API 接口说明
PHP RESTful API 接口说明
Python RESTful API 接口说明
RESTful API 各语言示例下载
实践教程
表结构设计
数据库交互
常见问题
信息咨询类
数据库使用类
数据库原理类
API 文档
History
Introduction
API Category
Making API Requests
Table Group APIs
Other APIs
Table APIs
Cluster APIs
Data Types
Error Codes
相关协议
服务等级协议
服务条款
词汇表
联系我们

insert

PDF
聚焦模式
字号
最后更新时间: 2024-12-04 09:56:31

简介

向表格中插入一条数据,可采用显示声明参数或传入文件两种方式操作。

语法

## 显示声明参数的值插入一条数据
insert into table (key1, key2, value1, vlaue2) values (1, "abc", 2, "def") [after -1] [shift none/head/tail];

## 从 csv 格式文件中读取并插入一条数据
insert into table infile result.csv [after -1] [shift none/head/tail];

## 从 xml 格式文件中读取并插入一条数据,该操作必须在启动 client 时提供 tdr 文件
insert into table infile result.xml [after -1] [shift none/head/tail] using tdr;

参数

参数
Protobuf 和 TDR
必填
table
表格的名字
key
主键字段名
value
非主键字段名
至少一个或*
after
LIST 表:
n > 0 表示从第 n 条数据插入
n = -2 表示从队首插入数据
n = -1 表示从队尾插入数据
n < -2 不支持
GENERIC 表:不支持 after 字段
shift
如果表格大小超过阈值(即表格的最大 size),可选择:
none:不淘汰数据
head:从队头淘汰
tail:从队尾淘汰数据
using tdr
Protobuf 表不支持此参数;TDR 表需要以 xml 格式插入数据,文件结构必须严格满足 xml 语法,该操作必须在启动 client 时提供 tdr 文件
infile
从文件中读取数据

错误

请参考 错误码列表

示例

示例文件下载:result.xmlresult.csv
tcaplus>insert into game_players (player_id,player_name,player_email,game_server_id) values (2,name,email,2);
insert success

insert time: 45322 us

tcaplus> Insert into table_list (uin, name, key1) values (99,99,99) after -1 shift tail;

insert success

insert time: 22464 us

tcaplus> Insert into table_list infile result.xml using tdr;


insert success

insert time: 9493 us

tcaplus> Insert into table_list infile result.csv;


insert success

insert time: 22368 us


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈