INSERT INTO

INSERT is an SQL statement that adds data to a table.

The INSERT statement has the format:

INSERT INTO tablename
VALUES (value1, value2, ...)

where tablename is the name of the table or view into which you want to insert data, and value1, value2, and so on, are the values you insert.

The list of data values after VALUES must correspond with the list of columns in the table into which they are inserted. There must be the same number of values as columns, and each value must have a data type that agrees with its column. As shown in the following example, null values can be inserted by writing NULL.

This statement:

INSERT INTO PERS
VALUES (400, 'HARRISON', 20, 'SALES', NULL, 18000.66, 0)

Inserts this line into the table PERS:

   ID  NAME         DEPT  JOB     YEARS     SALARY       COMM
------ ---------  ------  -----  ------  ---------  ---------
  400  HARRISON       20  SALES       -   18000.66       0.00

Table PERS is a copy of Q.STAFF; instructions for creating it are in CREATE TABLE. If you do not want to use the CREATE TABLE statement, you can also create PERS with these two commands:

DISPLAY Q.STAFF
SAVE DATA AS PERS
[ Previous Page | Next Page | Contents | Index ]