10.6. SELECT Output Columns

| 10.6. `SELECT` Output Columns  |                   |                           |                  |                     |
|:------------------------------:|-------------------|---------------------------|------------------|---------------------|
|[Prev](typeconv-union-case.html)|[Up](typeconv.html)|Chapter 10. Type Conversion|[Home](index.html)| [Next](indexes.html)|

---

## 10.6. `SELECT` Output Columns

[]()

The rules given in the preceding sections will result in assignment
of non-`unknown` data types to all expressions in an SQL query,
except for unspecified-type literals that appear as simple output
columns of a `SELECT` command. For example, in

```
SELECT 'Hello World';

```

 there is nothing to identify what type the string literal should be
taken as. In this situation PostgreSQL will fall back
to resolving the literal's type as `text`.

When the `SELECT` is one arm of a `UNION`(or `INTERSECT` or `EXCEPT`) construct, or when it
appears within `INSERT ... SELECT`, this rule is not applied
since rules given in preceding sections take precedence. The type of an
unspecified-type literal can be taken from the other `UNION` arm
in the first case, or from the destination column in the second case.

`RETURNING` lists are treated the same as `SELECT`output lists for this purpose.

### Note

 Prior to PostgreSQL 10, this rule did not exist, and unspecified-type literals in a `SELECT` output list were left as type `unknown`. That had assorted bad consequences, so it's been changed.

---

|      [Prev](typeconv-union-case.html)       |[Up](typeconv.html)| [Next](indexes.html)|
|:--------------------------------------------|:-----------------:|--------------------:|
|10.5. `UNION`, `CASE`, and Related Constructs|[Home](index.html) | Chapter 11. Indexes |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>