How to increase the length of a character varying datatype in Postgres without data loss

3 Comments

Run the following command:

alter table TABLE_NAME alter column COLUMN_NAME type character varying(120);

This will extend the character varying column field size to 120.

Remember to change TABLE_NAME to the relevant table name and COLUMN_NAME to the relevant column name.

Image Credits: Photo by Isis França on Unsplash.

0 0 vote
Article Rating

Related Articles

No results found.

Subscribe
Notify of
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
naspy
naspy
5 months ago

An example would have been really appreciated.

This did’nt bring enough information, because my query still doesn’t work

Aleksandar
Aleksandar
23 days ago
Reply to  naspy

example:
alter table TABLE_NAME alter column COLUMN_NAME type character varying(120);

description:
This will extend the character varying column field size to 120.

warning:
Remember to change TABLE_NAME to the relevant table name and COLUMN_NAME to the relevant column name.

Asim developer
Asim developer
3 months ago

thanks , you solved my problem

Menu
3
0
Would love your thoughts, please comment.x
()
x