File: insert.l.html

package info (click to toggle)
mpsql 2.0-2
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 2,912 kB
  • ctags: 5,665
  • sloc: ansic: 34,322; makefile: 3,525; sh: 17
file content (126 lines) | stat: -rw-r--r-- 4,331 bytes parent folder | download
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
120
121
122
123
124
125
126
<!-- manual page source format generated by PolyglotMan v3.0.4, -->
<!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->

<HTML>
<HEAD>
<TITLE>INSERT(SQL) manual page</TITLE>
</HEAD>
<BODY>
<A HREF="sql.html">SQL Reference Contents</A>
 
<H2><A NAME="sect0" HREF="#toc0">NAME </A></H2>
insert - insert tuples to a relation  
<H2><A NAME="sect1" HREF="#toc1">SYNOPSIS </A></H2>
<B>insert </B> into classname 
<BR>
     [(att.expr-1 [,att_expr.i] )] <BR>
     {<B>values </B> (expression1 [,expression-i] 
) | <BR>
     <B>select </B> [distinct] <BR>
     expression1 [,expression-i] <BR>
     [<B>from 
</B> from-list] [<B>where </B> qual]  <BR>
     [<B>group by </B> attr_name1 {, attr_name-i....}] <BR>
 
    [<B>union {all} select </B> ...] <BR>
  
<H2><A NAME="sect2" HREF="#toc2">DESCRIPTION </A></H2>
<B>Insert</B> adds instances that satisfy 
the qualification, <I>qual</I>, to <I>classname</I>. <I>Classname</I> must be the name of an 
existing class.  The target list specifies the values of the fields to 
be appended to <I>classname</I>. That is, each  <I>att_expr</I> specifies a field (either 
an attribute name or an attribute name plus an array specification) to 
which the corresponding  <I>expression</I> should be assigned.  The fields in 
the target list may be listed in any order.  Fields of the result class 
which do not appear in the target list default to NULL.  If the expression 
for each field is not of the correct data type, automatic type coercion 
will be attempted. <P>
An array initialization may take exactly one of the 
following forms: -- <BR>
 -- Specify a lower and upper index for each dimension 
 <BR>
 --  <BR>
 att_name[lIndex-1:uIndex-1]..[lIndex-i:uIndex-i] = array_str <BR>
 <P>
 -- <BR>
 --Specify 
only the upper index for each dimension <BR>
 --(each lower index defaults to 
1) <BR>
 -- <BR>
 att_name[uIndex-1]..[uIndex-i] = array_str <BR>
 <P>
 -- <BR>
 --Use the upper index bounds 
as specified within array_str <BR>
 --(each lower index defaults to 1) <BR>
 -- <BR>
 att_name 
= array_str <BR>
 where each <I>lIndex</I> or <I>uIndex</I> is an integer constant and <I>array_str</I> 
is an array constant (see <I><A HREF="pgintro.1.html">pgintro</I>(1)</A>
). <P>
<P>
 If the user does not specify any 
array bounds (as in the third form) then Postgres will attempt to deduce 
the actual array bounds from the contents of <I>array_str</I>. <P>
 If the user does 
specify explicit array bounds (as in the first and second forms) then 
the array may be initialized partly or fully  using a C-like syntax for 
array initialization.  However, the uninitialized array elements will contain 
garbage. <P>
You must have write or append access to a class in order to append 
to it, as well as read access on any class whose values are read in the 
target list or qualification (see <I>change <A HREF="acl.l.html">acl</I>(l)</A>
).  
<H2><A NAME="sect3" HREF="#toc3">EXAMPLES </A></H2>
-- <BR>
 --Make a new 
employee Jones work for Smith <BR>
 -- <BR>
 insert into emp <BR>
     select newemp.name, 
newemp.salary, <BR>
 <tt> </tt><tt> </tt>"Smith", 1990-newemp.age <BR>
 <tt> </tt><tt> </tt>from newemp <BR>
 <tt> </tt><tt> </tt>where name = "Jones" 
<BR>
 -- <BR>
 --Insert into newemp class to newemp <BR>
 -- <BR>
 insert into newemp <BR>
     select 
* from newemp1  <BR>
 -- <BR>
 --Create an empty 3x3 gameboard for noughts-and-crosses 
<BR>
 --(all of these queries create the same board attribute) <BR>
 -- <BR>
 insert into 
tictactoe (game, board[1:3][1:3]) <BR>
     values(1,'{{"","",""},{},{"",""}}') 
<BR>
 insert into tictactoe (game, board[3][3]) <BR>
     values (2,'{}') <BR>
 insert 
into tictactoe (game, board)  <BR>
     values (3,'{{,,},{,,},{,,}}') <BR>
  
<H2><A NAME="sect4" HREF="#toc4">SEE ALSO 
</A></H2>
create <A HREF="table.l.html">table(l)</A>
, create <A HREF="type.l.html">type(l)</A>
, <A HREF="update.l.html">update(l)</A>
, <A HREF="select.l.html">select(l)</A>
 <P>

<HR><P>
<A NAME="toc"><B>Table of Contents</B></A><P>
<UL>
<LI><A NAME="toc0" HREF="#sect0">NAME</A></LI>
<LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI>
<LI><A NAME="toc2" HREF="#sect2">DESCRIPTION</A></LI>
<LI><A NAME="toc3" HREF="#sect3">EXAMPLES</A></LI>
<LI><A NAME="toc4" HREF="#sect4">SEE ALSO</A></LI>
</UL>
</BODY></HTML>