changing a datatype | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

Hi @rbiri ,

When you change the datatype of an attribute, you have to update the database structure. While doing this, you can notice in SQL statement that the existing old data type column will get dropped and a new field will get created in the table with new datatype, with the same internal name.

ALTER TABLE SchemaName ADD COLUMN sMyColumn VARCHAR(255); ANALYZE SchemaName; ALTER TABLE SchemaName DROP COLUMN iMyColumn;

So while dropping the old data type column, all the data will also get deleted along with the field. And a new field will get created with the new data type and data will be empty for this field.

To save the data, you can export the data to a CSV file and after changing the data type and updating the database structure, import the file using import workflow and update the records into the schema.

3 replies

_Manoj_Kumar_
Community Advisor
Community Advisor
May 27, 2024

Hello @rbiri  If you are changing int to string then it should be ok. I have not done it myself but i would suggest testing it on a lower env first.

 

If you see anything is breaking then create a new attribute as string and move data from old attribute to new attribute by in the correct datatype. 

     Manoj     Find me on LinkedIn
ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
May 27, 2024

Hi @rbiri ,

When you change the datatype of an attribute, you have to update the database structure. While doing this, you can notice in SQL statement that the existing old data type column will get dropped and a new field will get created in the table with new datatype, with the same internal name.

ALTER TABLE SchemaName ADD COLUMN sMyColumn VARCHAR(255); ANALYZE SchemaName; ALTER TABLE SchemaName DROP COLUMN iMyColumn;

So while dropping the old data type column, all the data will also get deleted along with the field. And a new field will get created with the new data type and data will be empty for this field.

To save the data, you can export the data to a CSV file and after changing the data type and updating the database structure, import the file using import workflow and update the records into the schema.

 ~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
Sukrity_Wadhwa
Community Manager
Community Manager
June 13, 2024

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!

Sukrity Wadhwa