Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

SQL nube discovery

Posted by smathermather on June 4, 2011

Not sure this is standard SQL, but something I wanted to do is be able to cast new columns as a defined type while creating them on the fly with a SELECT statement.  In this way, I might, for example, UNION or UNION ALL two dissimilar tables on the fly with a VIEW.  In PostgreSQL this can be done easily, e.g.:


SELECT 1::smallint as gid, 'aaaah!'::text as mytextfield, a.gid as gid1, a.the_geom
	FROM base.wetlands_06 AS a;

The “::” serves as the cast.  I’ll have an upcoming post restructuring our data for serving in GeoServer as a VIEW to maximize legend support for GeoExt.  John, one of my interns, will be the guest blogger.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: