Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 9b6cc37ce608401d44f6535a0c7cb777 > files > 1034

postgresql11-docs-11.5-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>10.6. SELECT Output Columns</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="typeconv-union-case.html" title="10.5. UNION, CASE, and Related Constructs" /><link rel="next" href="indexes.html" title="Chapter 11. Indexes" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">10.6. <code xmlns="http://www.w3.org/1999/xhtml" class="literal">SELECT</code> Output Columns</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="typeconv-union-case.html" title="10.5. UNION, CASE, and Related Constructs">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="typeconv.html" title="Chapter 10. Type Conversion">Up</a></td><th width="60%" align="center">Chapter 10. Type Conversion</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 11.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="indexes.html" title="Chapter 11. Indexes">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="TYPECONV-SELECT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">10.6. <code class="literal">SELECT</code> Output Columns</h2></div></div></div><a id="id-1.5.9.11.2" class="indexterm"></a><p>
The rules given in the preceding sections will result in assignment
of non-<code class="type">unknown</code> data types to all expressions in a SQL query,
except for unspecified-type literals that appear as simple output
columns of a <code class="command">SELECT</code> command.  For example, in

</p><pre class="screen">
SELECT 'Hello World';
</pre><p>

there is nothing to identify what type the string literal should be
taken as.  In this situation <span class="productname">PostgreSQL</span> will fall back
to resolving the literal's type as <code class="type">text</code>.
</p><p>
When the <code class="command">SELECT</code> is one arm of a <code class="literal">UNION</code>
(or <code class="literal">INTERSECT</code> or <code class="literal">EXCEPT</code>) construct, or when it
appears within <code class="command">INSERT ... SELECT</code>, 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 <code class="literal">UNION</code> arm
in the first case, or from the destination column in the second case.
</p><p>
<code class="literal">RETURNING</code> lists are treated the same as <code class="command">SELECT</code>
output lists for this purpose.
</p><div class="note"><h3 class="title">Note</h3><p>
  Prior to <span class="productname">PostgreSQL</span> 10, this rule did not exist, and
  unspecified-type literals in a <code class="command">SELECT</code> output list were
  left as type <code class="type">unknown</code>.  That had assorted bad consequences,
  so it's been changed.
 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="typeconv-union-case.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="typeconv.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="indexes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">10.5. <code class="literal">UNION</code>, <code class="literal">CASE</code>, and Related Constructs </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 11. Indexes</td></tr></table></div></body></html>