Examples Of Insert - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

In addition to inserting values with specific data types, you might want to insert nulls. To insert
null, use the keyword NULL.

Examples of INSERT

Insert a row into the CUSTOMER table and supply the value 'A2' for the CREDIT column:
INSERT INTO sales.customer
VALUES (4777, 'ZYROTECHNIKS', '11211 40TH ST.',
--- 1 row(s) inserted.
The column name list is not specified for this INSERT statement. This operation works
because the number of values listed in the VALUES clause is equal to the number of columns
in the CUSTOMER table, and the listed values appear in the same order as the columns
specified in the CREATE TABLE statement for the CUSTOMER table.
By issuing this SELECT statement, this specific order is displayed:
SELECT * FROM sales.customer
WHERE custnum = 4777;
CUSTNUM
-------
4777
--- 1 row(s) selected.
Insert a row into the CUSTOMER table:
INSERT INTO sales.customer
(custnum, custname, street, city, state, postcode)
VALUES (1120, 'EXPERT MAILERS', '5769 N. 25TH PLACE',
--- 1 row(s) inserted.
Unlike the previous example, this INSERT does not include a value for the CREDIT column,
which has a default value. As a result, this INSERT must include the column name list.
This SELECT statement shows the default value 'C1' for CREDIT:
SELECT * FROM sales.customer
WHERE custnum = 1120;
CUSTNUM
-------
1120
--- 1 row(s) selected.
Insert multiple rows into the JOB table by using only one INSERT statement:
INSERT INTO persnl.job
VALUES (100,'MANAGER'),
--- 10 row(s) inserted.
'BURLINGTON', 'MASS.', '01803', 'A2');
CUSTNAME
STREET
-------------
--------------
ZYROTECHNIKS
11211 4OTH ST. ... 01803
'PHOENIX', 'ARIZONA', '85016');
CUSTNAME
STREET
--------------
--------------
EXPERT MAILERS
5769 N. 25TH.
(200,'PRODUCTION SUPV'),
(250,'ASSEMBLER'),
(300,'SALESREP'),
(400,'SYSTEM ANALYST'),
(420,'ENGINEER'),
(450,'PROGRAMMER'),
(500,'ACCOUNTANT'),
(600,'ADMINISTRATOR'),
(900,'SECRETARY');
... POSTCODE
CREDIT
--------
------
A2
... POSTCODE
CREDIT
--------
------
... 85016
C1
INSERT Statement
125

Advertisement

Table of Contents
loading

Table of Contents