本文為您介紹SQL搜尋樣本。
- 樣本1:搜尋上海地區具有標籤
business:online的所有Elastic Compute Service執行個體。SQL語句如下:SELECT ResourceId, ResourceName WHERE ResourceType='ACS::ECS::Instance' AND RegionId='cn-shanghai' AND Tags.Kvpair='business:online'說明 標籤的格式為Key:Value。 - 樣本2:搜尋具有標籤
product且記憶體為1 GB的所有Elastic Compute Service執行個體。SQL語句如下:SELECT COUNT(1) WHERE ResourceType='ACS::ECS::Instance' AND Memory=1024 AND Tags.Key='product' - 樣本3:搜尋
2021-01-01 00:00:00之後建立的所有Elastic Compute Service執行個體。SQL語句如下:SELECT ResourceId, ResourceName WHERE ResourceType = 'ACS::ECS::Instance' AND ResourceCreationTime > '2021-01-01 00:00:00' - 樣本4:搜尋IPv4地址為
198.168.XX.XX的Elastic Compute Service的彈性網卡。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