How to create PostgreSQL User with superuser privileges

In this article, we will see how to create PostgreSQL User with superuser privileges by two ways.

Create PostgreSQL User/Role with superuser privileges by using either of following methods:
1. Create User/Role first then assign superuser privilege.
2. Create User/Role with superuser privileges.

Continue reading How to create PostgreSQL User with superuser privileges

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 move tables from one schema to another in PostgreSQL

In this article, we will see how to move tables from one schema to another in PostgreSQL. We can move the tables from one schema to another by using alter table command. Schemas are database objects. Same schema can be exists in different. But, tables of schema are different.

Syntax:

ALTER TABLE table_name SET SCHEMA schema_name;

Examples to move tables from one schema to another in PostgreSQL:
Continue reading How to move tables from one schema to another in PostgreSQL

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 set permanent schema path to user in PostgreSQL

In this article, we will see how to set permanent schema path to user in PostgreSQL with examples. We can set it by using ALTER ROLE command.

Syntax to set permanent schema path to user in PostgreSQL:
Continue reading How to set permanent schema path to user in PostgreSQL

How to enable archive mode in PostgreSQL

In this article, we will see how to enable archive mode in PostgreSQL. Archive mode is not enabled by default in PostgreSQL.

What is archiving

Archiving is the concept to store history in a safe location. This also helps with Point In Time Recovery(PITR) and also in situations where a standby is lagging behind the primary and requires the recently removed WAL segments to get back to sync.

Steps to enable archive mode in PostgreSQL:
Continue reading How to enable archive mode in PostgreSQL

How to rename table in PostgreSQL

In this article, we will see how to rename table in PostgreSQL. We can rename a table by using alter command.

Syntax to rename table in PostgreSQL:

ALTER TABLE table_name RENAME TO new_table_name;

Examples:
Continue reading How to rename table in PostgreSQL

How to change owner of database in PostgreSQL

In this tutorial, we will see How to change owner of database in PostgreSQL. We can change the database owner by using ALTER DATABASE command. If we change the owner name, only database owner name will cnage. But not objects(tables, views,…) owners.

Syntax to change the owner of the database in PostgreSQL: Continue reading How to change owner of database 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

How to rename PostgreSQL Table

In this article, we will see how to rename PostgreSQL Table. ALTER TABLE is the command used to rename table in PostgreSQL Server. To execute ALTER TABLE, we must be owner of table or superuser or granted alter table permission on the table.

PostgreSQL Rename Table Syntax:

ALTER TABLE name RENAME TO new_name

Continue reading How to rename PostgreSQL Table