Inserting rows using the VALUES clause

You use the VALUES clause in the INSERT statement to insert a single row or multiple rows into a table.

An example of this is to insert a new row into the DEPARTMENT table. The columns for the new row are as follows:

  • Department number (DEPTNO) is 'E31'
  • Department name (DEPTNAME) is 'ARCHITECTURE'
  • Manager number (MGRNO) is '00390'
  • Reports to (ADMRDEPT) department 'E01'

The INSERT statement for this new row is as follows:

INSERT INTO DEPARTMENT (DEPTNO, DEPTNAME, MGRNO, ADMRDEPT)
   VALUES('E31', 'ARCHITECTURE', '00390', 'E01')

You can also insert multiple rows into a table using the VALUES clause. The following example inserts two rows into the PROJECT table. Values for the Project number (PROJNO) , Project name (PROJNAME), Department number (DEPTNO), and Responsible employee (RESPEMP) are given in the values list. The value for the Project start date (PRSTDATE) uses the current date. The rest of the columns in the table that are not listed in the column list are assigned their default value.

INSERT INTO PROJECT (PROJNO, PROJNAME, DEPTNO, RESPEMP, PRSTDATE)
   VALUES('HG0023', 'NEW NETWORK', 'E11', '200280', CURRENT DATE),
         ('HG0024', 'NETWORK PGM', ''E11", '200310', CURRENT DATE)