Saturday , April 20 2024

How To Change Column’s Data Type in PostgreSQL

Suppose that we created a table in the database by following the normalization rules for our application. However, we realized that the data type of the column was inconvenient. In such a case, we do not need to drop and create the table to change the data type.

In a different scenario, we try to insert the data into the table, but we realize that the column size is not enough.

In such cases, you can change column’s data type in two ways in PostgreSQL.

Change PostgreSQL Column’s Data Type

First Method

Re-create the table.

Second Method

Change the point of the table. In this method, the data type of the column can be changed by changing the metadata information in the table without the need to drop-create.

You can change column’s data type with the command below or with applications like pgadmin.

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories