db2 Hello World; Inserting a row into a DB2 table


Example

Let's suppose we are going to insert rows in the previously created table.

We can explicitly name the columns we are going to out values is and its order:

INSERT INTO EMPLOYEE (EMPNO, FIRSTNME, LASTNAME, SALARY)
  VALUES ( '123456', 'Ali', 'Veli', 100000);

If we know the order and we are going to put values for all columns we can write:

INSERT INTO EMPLOYEE
  VALUES ( '123456', 'Ali', 'Veli', 100000);

When using the db2clp, we need to put quotes because of the parenthesis (without semicolon at the end):

db2 "INSERT INTO EMPLOYEE (EMPNO, FIRSTNME, LASTNAME, SALARY)
  VALUES ( '123456', 'Ali', 'Veli', 100000)"