Adding Rows Using the INSERT Statement

The following information are required in an INSERT statement:

  • The table name
  • The column names
  • The actual value for the columns

Insert statement has to specify the value for primary key and NOT NULL columns. The following INSERT statement adds a row to the employee table. The order of values in the VALUES clause matches the order in which the columns are specified in the column list.


SQL> CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
  2                    ENAME VARCHAR2(10),
  3                    JOB VARCHAR2(9),
  4                    SAL NUMBER(7, 2),
  5                    DEPTNO NUMBER(2));

Table created.

SQL>
SQL> INSERT INTO EMP (EMPNO,ENAME,JOB,SAL,DEPTNO)VALUES (1, 'SMITH', 'CLERK',     800,    20);

1 row created.

SQL>
SQL> SELECT * from EMP;

     EMPNO ENAME      JOB              SAL     DEPTNO
---------- ---------- --------- ---------- ----------
         1 SMITH      CLERK            800         20

SQL>
SQL>
SQL>
SQL>
Home »
Oracle »
Table » 

Insert:
  1. Adding Rows Using the INSERT Statement
  2. Omitting the Column List
  3. Specifying a Null Value for a Column
  4. Single and Double Quotes and INSERT
  5. Copying Rows from One Table to Another with INSERT
Related: