# How to create a retention policy for measurement?

**URL:** <https://community.influxdata.com/t/how-to-create-a-retention-policy-for-measurement/21190>\
**Category:** Systems\
**Tags:** influxdb\
**Created:** [August 12, 2021, 10:14am UTC](https://community.influxdata.com/t/how-to-create-a-retention-policy-for-measurement/21190 "2021-08-12T10:14:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangjing](https://avatars.discourse-cdn.com/v4/letter/z/73ab20/32.png) [@zhangjing](https://community.influxdata.com/u/zhangjing)\
**Post date:** [August 12, 2021, 10:14am UTC](https://community.influxdata.com/t/how-to-create-a-retention-policy-for-measurement/21190/1 "2021-08-12T10:14:26Z")

</div>

I want to create a retention policy for measurement. By learning the doc I know that can creat a policy  
for database【CREATE RETENTION POLICY \<retention\_policy\_name\> ON \<database\_name\> DURATION REPLICATION [SHARD DURATION] [DEFAULT]】.Will this retention policy delete all measurements data? What should I do to delete only the data of one measurement。Will this strategy delete continuous queries?Could you please help me .thanks a lot .

---

<div class="post-metadata">

**Author:** ![zhangjing](https://avatars.discourse-cdn.com/v4/letter/z/73ab20/32.png) [@zhangjing](https://community.influxdata.com/u/zhangjing)\
**Post date:** [August 13, 2021, 3:57am UTC](https://community.influxdata.com/t/how-to-create-a-retention-policy-for-measurement/21190/2 "2021-08-13T03:57:48Z")

</div>

I have solved this. create a no default retention policy . Setting the retention policy when creating data.

> create database telegraf  
> use telegraf  
> Using database telegraf  
> create retention policy “rp-one-year” on “telegraf” duration 365d replication 1  
> show retention policies on telegraf  
> name duration shardGroupDuration replicaN default

* * *

autogen 0s 168h0m0s 1 true  
rp-one-year 8760h0m0s 168h0m0s 1 false

> insert into “rp-one-year” devops-idc-sz,host=server01 cpu=23.1,mem=0.63  
> select \* from “devops-idc-sz”
> 
> select \* from “rp-one-year”.“devops-idc-sz”  
> name: devops-idc-sz  
> time cpu host mem

* * *

1571296987607266011 23.1 server01 0.63

> select \* from “telegraf”.“rp-one-year”.“devops-idc-sz”  
> name: devops-idc-sz  
> time cpu host mem

* * *

1571296987607266011 23.1 server01 0.63
