Q:

How to update raster metadata in postgis

How can I update the raster metadata in postgis?
 upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands 
------------+------------+-------+--------+--------+--------+-------+-------+------+----------
          0 |          0 |   600 |    900 |      1 |     -1 |     0 |     0 | 4236 |        1

to
 upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands 
------------+------------+-------+--------+--------+--------+-------+-------+------+----------
        137 |         56 |   600 |    900 |      1 |     -1 |     0 |     0 | 4236 |        1

I tried:
UPDATE vol SET (ST_Metadata(rast)).upperleftx=137
    FROM (SELECT (ST_Metadata(rast)).upperleftx FROM vol) as foo;

or
UPDATE vol SET (ST_Metadata(rast)).upperleftx=137

It is an idea, but this doesn't work.

A:

You can't directly in one step, as far as I know. Raster_columns and raster_overviews are both views. This was done by design to prevent mismatches between constraints, meta data and actual data. You can see the definition of these views if you look in the file rtpostgis.sql that comes in the contrib/postgis/ folder of the postgres directory. All of this information is stored in  pg_class, pg_constraint, pg_attribute, etc, so you probably could alter them directly if you were really brave.
However, you can set upperleftx, upperlefty, scalex, scaley, skewx, etc using RT_ST_SetGeoReference. To reset the other values, you can drop and then re-add the constraints, using DropRasterConstraints followed by AddRasterConstraints. 
You didn't ask, but just to give you an idea of how bad an idea it would be to try and do this directly, here is the definition of the raster_columns view:
CREATE OR REPLACE VIEW raster_columns AS
    SELECT
            current_database() AS r_table_catalog,
            n.nspname AS r_table_schema,
            c.relname AS r_table_name,
            a.attname AS r_raster_column,
            COALESCE(_raster_constraint_info_srid(n.nspname, c.relname, a.attname), (SELECT ST_SRID('POINT(0 0)'::geometry))) AS srid,
            _raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'x') AS scale_x,
            _raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'y') AS scale_y,
            _raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'width') AS blocksize_x,
            _raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'height') AS blocksize_y,
            COALESCE(_raster_constraint_info_alignment(n.nspname, c.relname, a.attname), FALSE) AS same_alignment,
            COALESCE(_raster_constraint_info_regular_blocking(n.nspname, c.relname, a.attname), FALSE) AS regular_blocking,
            _raster_constraint_info_num_bands(n.nspname, c.relname, a.attname) AS num_bands,
            _raster_constraint_info_pixel_types(n.nspname, c.relname, a.attname) AS pixel_types,
            _raster_constraint_info_nodata_values(n.nspname, c.relname, a.attname) AS nodata_values,
            _raster_constraint_info_out_db(n.nspname, c.relname, a.attname) AS out_db,
            _raster_constraint_info_extent(n.nspname, c.relname, a.attname) AS extent
    FROM
            pg_class c,
            pg_attribute a,
            pg_type t,
            pg_namespace n
    WHERE t.typname = 'raster'::name
            AND a.attisdropped = false
            AND a.atttypid = t.oid
            AND a.attrelid = c.oid
            AND c.relnamespace = n.oid
            AND c.relkind = ANY(ARRAY['r'::char, 'v'::char, 'm'::char, 'f'::char])
            AND NOT pg_is_other_temp_schema(c.relnamespace);

