Thread: Changing the Datatype from Bit to Boolean.

Changing the Datatype from Bit to Boolean.

From
Gambhir Singh
Date:

Hi,

Aurora PostgreSQL DB has a table in which one column has the datatype BIT(1). Now the requirement is that I have to change the datatype of that column from BIT to BOOLEAN. There are only a few rows in the table.

--
Thanks & Regards
Gambhir Singh

Re: Changing the Datatype from Bit to Boolean.

From
hellen jiang
Date:

you can add one new column(boolean) and then remove the BIT column。

On Sun, Feb 23, 2025, 12:58 AM Gambhir Singh <gambhir.singh05@gmail.com> wrote:

Hi,

Aurora PostgreSQL DB has a table in which one column has the datatype BIT(1). Now the requirement is that I have to change the datatype of that column from BIT to BOOLEAN. There are only a few rows in the table.

--
Thanks & Regards
Gambhir Singh

Re: Changing the Datatype from Bit to Boolean.

From
Mark Smith
Date:
I am new to PostgreSQL. I am trying to restore a db downloaded from GitHub. Pg_restore is coming with error when tried using pgAdmin.  Can you tell what the reason could be?

Thanks for your help.

Mark

From: hellen jiang <hellenjiang99@gmail.com>
Sent: Sunday, February 23, 2025 8:13:05 AM
To: Gambhir Singh <gambhir.singh05@gmail.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Re: Changing the Datatype from Bit to Boolean.
 

you can add one new column(boolean) and then remove the BIT column。

On Sun, Feb 23, 2025, 12:58 AM Gambhir Singh <gambhir.singh05@gmail.com> wrote:

Hi,

Aurora PostgreSQL DB has a table in which one column has the datatype BIT(1). Now the requirement is that I have to change the datatype of that column from BIT to BOOLEAN. There are only a few rows in the table.

--
Thanks & Regards
Gambhir Singh

Re: Changing the Datatype from Bit to Boolean.

From
Holger Jakobs
Date:
Don't hijack threads!
--
Holger Jakobs, Bergisch Gladbach
Tel. +49 178 9759012


Am 23. Februar 2025 15:46:10 MEZ schrieb Mark Smith <mark@zoneget.com>:
I am new to PostgreSQL. I am trying to restore a db downloaded from GitHub. Pg_restore is coming with error when tried using pgAdmin.  Can you tell what the reason could be?

Thanks for your help.

Mark

From: hellen jiang <hellenjiang99@gmail.com>
Sent: Sunday, February 23, 2025 8:13:05 AM
To: Gambhir Singh <gambhir.singh05@gmail.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Re: Changing the Datatype from Bit to Boolean.
 

you can add one new column(boolean) and then remove the BIT column。

On Sun, Feb 23, 2025, 12:58 AM Gambhir Singh <gambhir.singh05@gmail.com> wrote:

Hi,

Aurora PostgreSQL DB has a table in which one column has the datatype BIT(1). Now the requirement is that I have to change the datatype of that column from BIT to BOOLEAN. There are only a few rows in the table.

--
Thanks & Regards
Gambhir Singh

Re: Changing the Datatype from Bit to Boolean.

From
Mark Smith
Date:
Hi Benjamin

Thanks for your help. The script to upload *.sql worked well.

Mark

From: Benjamin Acquaye <benjaminacquaye2@gmail.com>
Sent: Sunday, February 23, 2025 9:01:44 AM
To: Mark Smith <mark@zoneget.com>
Subject: Re: Changing the Datatype from Bit to Boolean.
 
Bro, this issue you're encountering with pg_restore could stem from a few different factors, 
and some of the common reasons and solutions.

1. Database Format Mismatch
The backup file you're trying to restore might not be in the right format. 
PostgreSQL supports several backup formats:

Custom format (.backup): This is often created with pg_dump.
=============
Plain SQL format (.sql): This is a plain text file containing SQL commands.
=================
Directory format: A directory structure, also generated by pg_dump.
=================

Solution:
=========
If you're trying to restore from a .sql file, you should use psql instead of pg_restore. 
==========================================================================================
==>psql -U your_user -d your_db_name -f backup.sql

If it's a .backup or directory format, you should use pg_restore. Example:
==========================================================================
==>pg_restore -U your_user -d your_db_name your_backup_file.backup

Solution: 
Make sure the user you're logged in as has the appropriate permissions to create objects in the database.

==>GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_user;

On Sun, Feb 23, 2025 at 9:46 AM Mark Smith <mark@zoneget.com> wrote:
I am new to PostgreSQL. I am trying to restore a db downloaded from GitHub. Pg_restore is coming with error when tried using pgAdmin.  Can you tell what the reason could be?

Thanks for your help.

Mark

From: hellen jiang <hellenjiang99@gmail.com>
Sent: Sunday, February 23, 2025 8:13:05 AM
To: Gambhir Singh <gambhir.singh05@gmail.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Re: Changing the Datatype from Bit to Boolean.
 

you can add one new column(boolean) and then remove the BIT column。

On Sun, Feb 23, 2025, 12:58 AM Gambhir Singh <gambhir.singh05@gmail.com> wrote:

Hi,

Aurora PostgreSQL DB has a table in which one column has the datatype BIT(1). Now the requirement is that I have to change the datatype of that column from BIT to BOOLEAN. There are only a few rows in the table.

--
Thanks & Regards
Gambhir Singh

Re: Changing the Datatype from Bit to Boolean.

From
shammat@gmx.net
Date:
Gambhir Singh schrieb am 23.02.2025 um 06:56:
> Aurora PostgreSQL DB has a table in which one column has the
> datatype BIT(1). Now the requirement is that I have to change the
> datatype of that column from BIT to BOOLEAN. There are only a few
> rows in the table.
If you store 1 as true and 0 as false, you can use something like this:

alter table the_table
   alter the_column type boolean using (the_column = '1');