# Hi everyone, How to dynamically rename the table name based on data changes?

**URL:** <https://discourse.getdbt.com/t/hi-everyone-how-to-dynamically-rename-the-table-name-based-on-data-changes/5100>\
**Category:** Help\
**Tags:** jinja, redshift\
**Created:** [October 17, 2022, 5:03pm UTC](https://discourse.getdbt.com/t/hi-everyone-how-to-dynamically-rename-the-table-name-based-on-data-changes/5100 "2022-10-17T17:03:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sravya.k](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/sravya.k/32/1239_2.png) [@sravya.k](https://discourse.getdbt.com/u/sravya.k)\
**Post date:** [October 17, 2022, 5:03pm UTC](https://discourse.getdbt.com/t/hi-everyone-how-to-dynamically-rename-the-table-name-based-on-data-changes/5100/1 "2022-10-17T17:03:05Z")

</div>

Example:  
Currently we have 2020 year data so table created as xxx\_2020 but later the data in the table changes and contains 2021 data then table should be renamed to xxx\_2021

Table 2020 should be renamed to 2021.

---

<div class="post-metadata">

**Author:** ![jeffsk](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jeffsk/32/1250_2.png) [@jeffsk](https://discourse.getdbt.com/u/jeffsk)\
**Post date:** [October 18, 2022, 5:16am UTC](https://discourse.getdbt.com/t/hi-everyone-how-to-dynamically-rename-the-table-name-based-on-data-changes/5100/2 "2022-10-18T05:16:28Z")

</div>

In dbt, the table name is the model name. We don’t dynamically rename models. (Nor can I imagine wanting to split tables up by years!)

Can you share more about your use cases?

---

<div class="post-metadata">

**Author:** ![stephen](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@stephen](https://discourse.getdbt.com/u/stephen)\
**Post date:** [November 2, 2022, 3:05am UTC](https://discourse.getdbt.com/t/hi-everyone-how-to-dynamically-rename-the-table-name-based-on-data-changes/5100/3 "2022-11-02T03:05:09Z")

</div>

It appears like you are trying to shard your data based on `year`. In that case you should look into table partitioning based on your datawarehouse.

---

<div class="post-metadata">

**Author:** ![hiteshmusale11](https://avatars.discourse-cdn.com/v4/letter/h/3be4f8/32.png) [@hiteshmusale11](https://discourse.getdbt.com/u/hiteshmusale11)\
**Post date:** [January 6, 2023, 9:17am UTC](https://discourse.getdbt.com/t/hi-everyone-how-to-dynamically-rename-the-table-name-based-on-data-changes/5100/4 "2023-01-06T09:17:28Z")

</div>

In my case, I am reading data from oracle where month wise tables are created  
e.g : tbl\_name202301

I want to create incremental dbt model where it should dynamically change the model name as per the oracle table names .

Help will be appreciated.
