Error Column Cannot Be Cast To Type Bytea
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings how to change column data type in postgresql and policies of this site About Us Learn more about Stack Overflow
Postgres Alter Column Integer To Varchar
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Cannot Be Cast Automatically To Type Integer Rails
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Cannot Be Cast Automatically To Type Integer Django
only takes a minute: Sign up PostgreSQL - ERROR: column “date” cannot be cast to type date up vote 3 down vote favorite 1 I want to cast a specific column in my PostgreSQL database from character_varying type to type date. phpPgAdmin gives me the following error: ERROR: column "date" cannot be cast to type date In Statement: ALTER TABLE column cannot be cast automatically to type integer postgresql "public"."tablename" ALTER COLUMN "date" TYPE date What should I do ? Thanks postgresql date casting share|improve this question edited Feb 15 '13 at 18:45 asked May 11 '11 at 15:45 Athanasios Emmanouilidis 7271918 add a comment| 1 Answer 1 active oldest votes up vote 13 down vote accepted You might need to convert it to text first: alter table "foo" alter column "date" type date using ("date"::text::date); share|improve this answer answered May 11 '11 at 15:52 Denis de Bernardy 46.4k562106 Hi and thanks for the answer. I have another problem. The date column is used in one of my views so i get the following error: ERROR: cannot alter type of a column used by a view or rule How can i overcome this ? –Athanasios Emmanouilidis May 11 '11 at 16:03 In that case you cannot: you need to drop the view and recreate it. –Denis de Bernardy May 11 '11 at 16:04 If you want to save or see the definition of the view, it's stored in pg_views btw.
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists Regional lists Associations User groups default for column cannot be cast automatically to type integer Project lists Inactive lists IRC Local User Groups Featured specify a using expression to perform the conversion rails Users International Sites Propaganda Resources Weekly News Altering column type from text to bytea From: rails migration using Alexander Reichstadt
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://dba.stackexchange.com/questions/6205/how-to-change-the-datatype-of-a-column-from-integer-to-money Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it cannot be works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top How to change the datatype of a column from integer to money? up vote 4 down vote favorite 1 I am attempting to convert a PostgreSQL table column from integer to money, but I am receiving the error: cannot cast type MyColumn to money I have tried these cannot be cast two statements, but just haven't found any real example on how to really do it. ALTER TABLE products ALTER COLUMN price TYPE money and: ALTER TABLE products ALTER COLUMN price TYPE money USING to_char(price, '999.99') How can you change the datatype of a PostgreSQL column from integer to money? postgresql datatypes alter-table money share|improve this question edited Sep 27 '11 at 14:05 p.campbell 26026 asked Sep 27 '11 at 0:49 Gabriel 21112 What version of postgres are you running? –Jack Douglas♦ Sep 28 '11 at 9:31 add a comment| 3 Answers 3 active oldest votes up vote 6 down vote Just try the following command. ALTER TABLE products ALTER COLUMN price TYPE money using price::text::money Non-quoted numeric values can be converted to money by casting the numeric value to text and then money share|improve this answer edited Sep 28 '11 at 3:19 answered Sep 27 '11 at 3:28 francs 787819 add a comment| up vote 3 down vote Try ALTER TABLE products ALTER COLUMN price TYPE money USING price::money btw what error did you get on your second try up there? share|improve this answer answered Sep 27 '11 at 2:39 Scott Marlowe 96658 add a comment| up vote 3 d