How to find all columns of a table in PostgreSQL

In this article, we will see how to find all columns of a table in PostgreSQL.

A postgresql table not only contains user defined columns. It also adds column names like xmin, xmax,….

Find the all column names: Continue reading How to find all columns of a table in PostgreSQL

PostgreSQL ERROR: syntax error at or near “VARCHAR”

In this article, we will see the solution for ERROR: syntax error at or near “VARCHAR”.

PostgreSQL ERROR: syntax error at or near "VARCHAR"

Reolution: Continue reading PostgreSQL ERROR: syntax error at or near “VARCHAR”

How to drop multiple columns in PostgreSQL

In this article, we will see how to drop multiple columns in PostgreSQL with examples. We can drop columns by using alter table command.

Syntax to drop multiple columns in PostgreSQL
Continue reading How to drop multiple columns in PostgreSQL

How to change column datatype in PostgreSQL

In this article, we will see how to change column datatype in PostgreSQL. We can change the data type of a column by using the ALTER TABLE statement.

Two scenarios are there:
1. Change column datatype of table with data.
2. Change column datatype of table without data.

PostgreSQL change column data type statement:

To change the data type of a column, you use the ALTER TABLE statement as follows:

ALTER TABLE table_name ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]

Continue reading How to change column datatype in PostgreSQL

How to rename column in PostgreSQL

In this article, we will see how to rename a column in PostgreSQL with examples using ALTER TABLE command with RENAME parameter.

To rename a column of a table, you use the ALTER TABLE statement with RENAME COLUMN clause as follows:

Syntax to PostgreSQL Rename column:

ALTER TABLE table_name RENAME COLUMN column_name TO new_column_name;

Continue reading How to rename column in PostgreSQL