title: Flink Create View or Table as Select
body: <p>I was reading the <a href="https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/sql/" rel="nofollow noreferrer">Flink SQL</a> docs and in the section on Create, I could not find anything that resembles <code>CREATE VIEW AS SELECT</code> nor CTAS.</p>
  <p>I looked a bit further and found the following:</p>
  <ul>
  <li>Flink SQL allows you to Select</li>
  <li>Flink SQL allows you to Create</li>
  <li>Flink SQL allows you to Insert</li>
  </ul>
  <p>As such, it seems like Flink SQL would allow you to imitate the capabilities of Create as Select, but without the convenience of automatically grabbing the schema of the source table.</p>
  <p>In addition, I found that:</p>
  <ul>
  <li>Flink (outside SQL) allows you to assign the output of an SQL Select statement to a new table (and presumably a view)</li>
  </ul>
  <p>For example:</p>
  <pre><code>Table result = tableEnv.sqlQuery(&quot;SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'&quot;);
  </code></pre>
  <p>Now my question:</p>
  <h1>(How) Does Flink allow you to Create as Select without leaving the SQL context</h1>
  <p>And based on the examples that I have seen this can likely be rephrased as:</p>
  <p>Can you create as select inside an <code>executeSql</code> statement.</p>