Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:10:34+00:00 2026-06-17T15:10:34+00:00

I am going to change the data type of a column from character varying

  • 0

I am going to change the data type of a column from “character varying” to “bigint” in postgre.

The old column contains string “male” and “female”, now I want to change it to 0 or 1, each representing male or female.

I think a simple Alter table … Alter Column does not solve this problem as it will not do the male -> 0, female -> 1 conversion.

Can anyone let me know what is the safest way to do this?

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:10:35+00:00Added an answer on June 17, 2026 at 3:10 pm

    Points to be considered

    1. When you are going to use 1 for Male and 0 for Female,
      why do you want to use bigint datatype? BIT/TINYINT datatype will work
    2. Before altering the datatype of the column,
      you need to update Male to 1 and Female to 0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When i am going to change the data type of column name i am
I'm designing a database application where data is going to change over time. I
We are going to change the connection string in Settings.vb so we don't need
I am going to change my working sphere from Enterprise Web Applications written for
I am going to change my hosting, and allready rented a new server. Now
Is the .Net 4 Framework going to change before the go-live or can we
i need an sql script that is going to change the datasource of all
set dateformat dmy select isdate('31/1/2012') I thought by going into Change the format of
I want to create a clone of the plug-in. I'm going to change the
I am writing an application which is going to allows users to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.