RDB/VMS SQL INSERT — VMS RDB_4.0
INSERT INTO ─┬─> table-name ──────────┬────┐ ├─> view-name ───────────┤ │ └─>
C
U
R
S
O
R cursor-name ─┘ │ ┌─────────────────────────────┘ └┬───────────────────────────┬─┐ └─> ( ─┬> column-name ┬─> ) ┘ │ └────── , <────┘ │ ┌──────────────────────────────┘ ├─>
V
A
L
U
E
S ──> ( ─┬┬─> literal ──────────┬┬─> ) ─┐ │ │├─> parameter ────────┤│ │ │ │├─>
N
U
L
L ─────────────┤│ │ │ │├─>
U
S
E
R ─────────────┤│ │ │ │└─>
C
U
R
R
E
N
T
T
I
M
E
S
T
A
M
P ┘│ │ │ └──── , <───────────────┘ │ │ ┌───────────────────────────────────────────┘ │ └┬───────────────────────────────────┬─┬───> typebox (;) │ └─>
R
E
T
U
R
N
I
N
G
D
B
K
E
Y typebox (I)typebox (N)typebox (T)typebox (O) parameter ─┘ │ │ │ └──> select-expr ───────────────────────────┘
Additional information available:
More InformationPositioned INSERTList INSERTcolumn nameselect expr
More Information
The INSERT statement stores data in the rows of a table. If you are storing data of data type LIST OF BYTE VARYING in your table, use a positioned insert to store one or more rows in an insert only table cursor. The positioned insert sets up the proper row context for a subsequent insert list cursor. After establishing row context, use a list insert to store data in the elements of a list within that table row. The positioned insert and list insert require special subsets of the INSERT statement syntax. For syntax, see Positioned_INSERT and List_INSERT.
Positioned INSERT
INSERT INTO CURSOR ───> cursor-name ──┐ ┌──────────────────────────────────┘ └─┬────────────────────────────┬───┐ └─> ( ─┬ column-name ─┬─> ) ─┘ │ └────── , <────┘ │ ┌──────────────────────────────────┘ │ └─>
V
A
L
U
E
S ──> ( ─┬┬─> literal ───┬┬──> ) ───>typebox (;) │├─> parameter ─┤│ │├─>
N
U
L
L ──────┤│ │└─>
U
S
E
R ──────┘│ └──── , <────────┘
List INSERT
INSERT INTO CURSOR ───> cursor-name ──┐ │ ┌────────────────────────────────────┘ └──>
V
A
L
U
E
S ──> ( ─┬┬─> literal ───┬┬─> ) ──> typebox (;) │└─> parameter ─┘│ └───── , <───────┘
column name
A list of names of columns in the table or view. You can list the columns in any order, but the names must correspond to those of the table or view. If you do not include all the column names in the list, SQL assigns a null value to those not specified, unless columns were defined with the NOT NULL clause in the CREATE TABLE statement. You must include in an INSERT statement all names of columns defined with the NOT NULL clause. Omitting the list of column names altogether is the same as listing all the columns of the table or view in the same order as they were defined.
RETURNING_DBKEY
Returns the database key (DBKEY) of the row being added. When the DBKEY value is valid, subsequent queries can use the DBKEY to access the record directly.
Additional information available:
INTO parameter
Inserts the database key (DBKEY) of the row to a specified parameter. The INTO parameter clause is not valid in interactive SQL.
select expr
select-expr =
───┬─┬─> select-clause ─────┬───>
│ └─>( select-expr ) ────┤
│ ┌─────────<────────────┘
│ └─>
U
N
I
O
N ─┬───────┬────┐
│ └─>
A
L
L ─┘ │
└───────<────────────────┘
Additional information available:
More Information
A select expression that specifies a result table. The result table can contain zero or more rows. All the rows of the result table are added to the target table named in the INTO clause. The number of columns in the result table must correspond to the number of columns specified in the list of column names. If you did not specify a list of column names, the number of columns in the result table must be the same as the number of columns in the target table. The value of the first column in the result table is assigned to the first column of the target table, the second value to the second column, and so on.
select clause
select-clause = SELECT ─┬──────>──────┬─> select-list ──┐ ├─>
A
L
L ──────┤ │ └─>
D
I
S
T
I
N
C
T ─┘ │ ┌──────────────────────────────<──────┘ └
F
R
O
M ─┬┬─> table-name ─┬─┬─────>────┬─┬─┬─────────>──────────┬─┐ │└─> view-name ──┘ └─> alias ─┘ │ └─>
W
H
E
R
E predicate ─┘ │ └────────── , <─────────────────┘ │ ┌──────────────────────────────<─────────────────────────────────┘ └┬─────────────>──────────────────┬─┬──────────>──────────┬──> └─>
G
R
O
U
P
B
Y ─┬─> column-name ─┬─┘ └─>
H
A
V
I
N
G predicate ─┘ └─────── , <─────┘ For more information on select expressions, see the online help topic on select_expr.
UNION
The union operator merges the results of a select expression or select clause with another select expression or select clause into one result table by appending the values of columns in one table with the values of columns in other tables.
Additional information available:
ALL
The ALL qualifier specifies that duplicate rows should not be eliminated from the result table.
VALUES
The VALUES clause specifies a list of values to be added to the table as a single row. The values can be specified through literals, paramters, or keywords NULL, USER, or CURRENT_TIMESTAMP. See Chapter 3 of the Reference Manual for more information about literals, parameters, and the NULL, USER, and CURRENT_TIMESTAMP keywords. The number of values in the list must correspond to the number of columns specified in the list of column names. If you did not specify a column list, the number of values in the list must be the same as the number of columns in the table. The first value specified in the list is assigned to the first column, the second value to the second, and so on.