本文为您介绍SQL搜索示例。
- 示例1:搜索上海地域具有标签
business:online
的所有云服务器ECS实例。SQL语句如下:SELECT ResourceId, ResourceName WHERE ResourceType='ACS::ECS::Instance' AND RegionId='cn-shanghai' AND Tags.Kvpair='business:online'
说明 标签的格式为Key:Value
。 - 示例2:搜索具有标签
product
且内存为1 GB的所有云服务器ECS实例。SQL语句如下:SELECT COUNT(1) WHERE ResourceType='ACS::ECS::Instance' AND Memory=1024 AND Tags.Key='product'
- 示例3:搜索
2021-01-01 00:00:00
之后创建的所有云服务器ECS实例。SQL语句如下:SELECT ResourceId, ResourceName WHERE ResourceType = 'ACS::ECS::Instance' AND ResourceCreationTime > '2021-01-01 00:00:00'
- 示例4:搜索IPv4地址为
198.168.XX.XX
的云服务器ECS的弹性网卡。SQL语句如下:SELECT * WHERE ResourceType = 'ACS::ECS::NetworkInterface' AND PrivateIpAddress = '198.168.XX.XX'
- 示例5:搜索每种资源的数量。
SQL语句如下:
SELECT ResourceType, COUNT(1) GROUP BY ResourceType ORDER BY COUNT(1) DESC