11single.mql 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. -- ============================================================
  2. -- 单分区测试
  3. -- ============================================================
  4. -- 1. 插入单分区数据
  5. insert into /test/aaa/test_partition (p_id, p_name, p_value) values (1, 'part1_item1', 100)
  6. ;
  7. insert into /test/aaa/test_partition (p_id, p_name, p_value) values (1, 'part1_item2', 200)
  8. ;
  9. insert into /test/aaa/test_partition (p_id, p_name, p_value) values (2, 'part2_item1', 300)
  10. ;
  11. insert into /test/aaa/test_partition (p_id, p_name, p_value) values (2, 'part2_item2', 400)
  12. ;
  13. -- 2. 查询单分区数据
  14. select * from /test/aaa/test_partition where p_id=1
  15. /**
  16. output()
  17. **/
  18. ;
  19. -- 3. 跨分区查询
  20. select * from /test/aaa/test_partition
  21. /**
  22. output()
  23. **/
  24. ;
  25. -- 4. 按分区聚合
  26. select p_id, count(*) from /test/aaa/test_partition group by p_id
  27. /**
  28. output()
  29. **/
  30. ;
  31. -- 5. 更新单分区数据
  32. update /test/aaa/test_partition set p_value=150 where p_id=1 and p_name='part1_item1'
  33. ;
  34. select p_value from /test/aaa/test_partition where p_id=1 and p_name='part1_item1'
  35. /**
  36. output()
  37. **/
  38. ;
  39. -- 6. 删除单分区数据
  40. delete from /test/aaa/test_partition where p_id=2 and p_name='part2_item2'
  41. ;
  42. select * from /test/aaa/test_partition where p_id=2 and p_name='part2_item2'
  43. /**
  44. output()
  45. count(0)
  46. **/
  47. ;