-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcreate-table.html
119 lines (105 loc) · 4.92 KB
/
create-table.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!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>7.2. CREATE TABLE — Presto 0.123 Documentation</title>
<link rel="stylesheet" href="../_static/presto.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.123',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Presto 0.123 Documentation" href="../index.html" />
<link rel="up" title="7. SQL Statement Syntax" href="../sql.html" />
<link rel="next" title="7.3. CREATE TABLE AS" href="create-table-as.html" />
<link rel="prev" title="7.1. ALTER TABLE" href="alter-table.html" />
</head>
<body>
<div class="header">
<h1 class="heading"><a href="../index.html">
<span>Presto 0.123 Documentation</span></a></h1>
<h2 class="heading"><span>7.2. CREATE TABLE</span></h2>
</div>
<div class="topnav">
<p class="nav">
<span class="left">
« <a href="alter-table.html">7.1. ALTER TABLE</a>
</span>
<span class="right">
<a href="create-table-as.html">7.3. CREATE TABLE AS</a> »
</span>
</p>
</div>
<div class="content">
<div class="section" id="create-table">
<h1>7.2. CREATE TABLE</h1>
<div class="section" id="synopsis">
<h2>Synopsis</h2>
<div class="highlight-none"><div class="highlight"><pre>CREATE TABLE [ IF NOT EXISTS ]
table_name (
column_name data_type [, ...]
)
[ WITH ( property_name = expression [, ...] ) ]
</pre></div>
</div>
</div>
<div class="section" id="description">
<h2>Description</h2>
<p>Create a new, empty table with the specified columns.
Use <a class="reference internal" href="create-table-as.html"><em>CREATE TABLE AS</em></a> to create a table with data.</p>
<p>The optional <tt class="docutils literal"><span class="pre">IF</span> <span class="pre">NOT</span> <span class="pre">EXISTS</span></tt> clause causes the error to be
suppressed if the table already exists.</p>
<p>The optional <tt class="docutils literal"><span class="pre">WITH</span></tt> clause can be used to set properties
on the newly created table. To list all available table
properties, run the following query:</p>
<div class="highlight-sql"><div class="highlight"><pre><span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="k">system</span><span class="p">.</span><span class="n">metadata</span><span class="p">.</span><span class="n">table_properties</span>
</pre></div>
</div>
</div>
<div class="section" id="examples">
<h2>Examples</h2>
<p>Create a new table <tt class="docutils literal"><span class="pre">orders</span></tt>:</p>
<div class="highlight-sql"><div class="highlight"><pre><span class="k">CREATE</span> <span class="k">TABLE</span> <span class="n">orders</span> <span class="p">(</span>
<span class="n">orderkey</span> <span class="nb">bigint</span><span class="p">,</span>
<span class="n">orderstatus</span> <span class="nb">varchar</span><span class="p">,</span>
<span class="n">totalprice</span> <span class="n">double</span><span class="p">,</span>
<span class="n">orderdate</span> <span class="nb">date</span>
<span class="p">)</span>
<span class="k">WITH</span> <span class="p">(</span><span class="n">format</span> <span class="o">=</span> <span class="s1">'ORC'</span><span class="p">)</span>
</pre></div>
</div>
<p>Create the table <tt class="docutils literal"><span class="pre">orders</span></tt> if it does not already exist:</p>
<div class="highlight-sql"><div class="highlight"><pre><span class="k">CREATE</span> <span class="k">TABLE</span> <span class="n">IF</span> <span class="k">NOT</span> <span class="k">EXISTS</span> <span class="n">orders</span> <span class="p">(</span>
<span class="n">orderkey</span> <span class="nb">bigint</span><span class="p">,</span>
<span class="n">orderstatus</span> <span class="nb">varchar</span><span class="p">,</span>
<span class="n">totalprice</span> <span class="n">double</span><span class="p">,</span>
<span class="n">orderdate</span> <span class="nb">date</span>
<span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="bottomnav">
<p class="nav">
<span class="left">
« <a href="alter-table.html">7.1. ALTER TABLE</a>
</span>
<span class="right">
<a href="create-table-as.html">7.3. CREATE TABLE AS</a> »
</span>
</p>
</div>
<div class="footer">
</div>
</body>
</html>