If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > how to change column datatype

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-11, 00:56
Rishi_raj2121 Rishi_raj2121 is offline
Registered User
 
Join Date: Oct 2011
Posts: 1
how to change column datatype

Hi all,
I have a table which is having 25 columns. I go to the properties of one column and try to change the data type from character varyfying to numeric but there is no option of numeric. How can i change its datatype from character to numeric?

If there is another solution then please tell me in detail as i am new to postgresql.



Thanks
Rishi
Reply With Quote
  #2 (permalink)  
Old 10-07-11, 03:28
shureg shureg is offline
Registered User
 
Join Date: Oct 2011
Location: Hamburg, Germany
Posts: 15
you cant change the datatype if the table is not empty on this way.

you need have to create new table a copy all data from old into new one.
Reply With Quote
  #3 (permalink)  
Old 10-07-11, 04:32
arvindps arvindps is offline
Registered User
 
Join Date: Aug 2011
Posts: 27
that is right,

but here is what you can do

a) add a new column say my_col as per your requirement
b) place all new values in this col, using update
c) delete the old column
Reply With Quote
Reply

Tags
postgresql

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On