![]() This looks like a bug to me - I do not have 9.0 or 9.1 to test on yet, hopefully someone else can't say if it is fixed in those versions or if we should raise it as a bug.Īside: your original will of course fail even with an explicit cast if there are any rows where price>=1000: alter table products alter column price type money using to_char(price, '999.99')::money ĮRROR: invalid input syntax for type money: " #. Note that while select to_char(78, '999.99')::money succeeds, the following fails: alter table products alter column price type money using to_char(price, '999.99') ĮRROR: column "price" cannot be cast to type moneyīut with an explicit cast it succeeds: alter table products alter column price type money using to_char(price, '999.99')::money It takes the approach of representing a binary string as a sequence of ASCII characters, while converting those bytes that cannot be represented as an ASCII character into special escape sequences. So, without any further delay, let’s start. ![]() This blog will present a step-by-step guide on changing the column’s data type. As francs already implied, there is no default cast from integer to money (until 9.1), instead you need an intermediate cast to text: select 78::integer::money The escape format is the traditional PostgreSQL format for the bytea type. In PostgreSQL, we can change the data type of one or more than one column using the ALTER TABLE and ALTER COLUMN commands.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |