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
相关协议
服务等级协议
服务条款
词汇表
联系我们

select

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

简介

用户可以使用 select 命令从数据库中获取指定的整条记录的值或部分记录的部分字段的值,如果没有匹配的记录,将会返回错误。

语法

select key1, key2, key3, value1, value2 [into result.csv] from table where key1 = 1 and key2 = "abc" [and -index = 1] [\\P] [\\G] [using tdr]
select * [into result.xml] from table where key1 = 1 and key2 = "abc" [and -index = 1] using tdr [\\P];

参数

参数
Protobuf
TDR
必填项
table
表格的名字
表格的名字
key
主键字段名,支持分布式索引查询,可填入部分 key 值
主键字段名,必须填入所有 key 值
value
非主键字段名
非主键字段名
至少一个或*
-index
LIST 表:如果指定“-index”会返回相同 key 下的第 index 条记录,如果不指定“-index”,则返回所有记录
GENERIC 表:不支持
LIST 表:如果指定“-index”会返回相同 key 下的第 index 条记录,如果不指定“-index”, 则返回所有记录
GENERIC 表:不支持
\\P
打印时延数据
打印时延数据
\\G
竖排打印
竖排打印
using tdr
不支持
以 xml 格式输出数据,文件结构必须严格满足 xml 语法,该操作必须在启动 client 时提供 tdr 文件
into
输出数据到文件
输出数据到文件

错误

请参考 错误码列表

示例

tcaplus> select * from test_table where gameid=1234 and itemid=12323 and name='testname';
+------+------+----------+------+----+-----+
|gameid|itemid|name |typeid|Data|uname|
+------+------+----------+------+----+-----+
|1234 |12323 |"testname"|0 |9 |"ab" |
+------+------+----------+------+----+-----+
1 records selectd, select time: 9802 us

tcaplus> select uname from test_table where gameid=1234 and itemid=12323 and name='testname';
+------+------+----------+-----+
|gameid|itemid|name |uname|
+------+------+----------+-----+
|1234 |12323 |"testname"|"ab" |
+------+------+----------+-----+
1 records selectd, select time: 9457 us

tcaplus> select * into test.txt from test_table where gameid=1234 and itemid=12323 and name='testname';
1 records are stored to test.csv, select time: 10198 us

tcaplus> select * from test_table where gameid=1234 and itemid=12323 and name='testname' \\P \\G;
gameid: 1234
itemid: 12323
name: "testname"
typeid: 0
Data: 9
uname: "ab"

API ---- -1us --->ProxyFront---- 10us --->ProxyEnd--- 364us --->SvrMainStart
| | | |381us
|11380us |4138us |4104us SvrWorkerStart
| | | |61us
API <--- 34197us ----ProxyFront<--- 24us ----ProxyEnd<-- 3298us ----SvrWorkerEnd
1 records selectd, select time: 11380 us


tcaplus> select * into table_list.xml from table_list where uin=99 and name = "99" and key1=99 using tdr;
11 records are stored to table_list.xml, select time: 135299 us

tcaplus> select c_string from table_list where uin=99 and name = "99" and key1=99;
+---+----+----+--------+
|uin|name|key1|c_string|
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
|99 |"99"|99 |"" |
+---+----+----+--------+
|99 |"99"|99 |"" |
+---+----+----+--------+
|99 |"99"|99 |"" |
+---+----+----+--------+
|99 |"99"|99 |"" |
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
11 records selectd, select time: 102572 us

tcaplus> select c_string from table_list where uin=99 and name = "99" and key1=99 and -index=9;
+---+----+----+--------+
|uin|name|key1|c_string|
+---+----+----+--------+
|99 |"99"|99 |" " |
+---+----+----+--------+
1 records selectd, select time: 9886 us

帮助和支持

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

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

文档反馈