Insert into select with where clause : Insert Select « Insert Update Delete « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE employee (
  2  id          number,
  3  name        varchar(100),
  4  birth_date  date,
  5  gender      varchar2(30) );

Table created.

SQL>
SQL> INSERT INTO employee (id,name,birth_date,gender ) SELECT 300,'H',NULL,'MALE' from   dual d
  2  where not exists (SELECT 1 FROM   employee x WHERE  x.id = '300' );

1 row created.

SQL>
SQL> select * from employee;

    ID
------
NAME
----------------------------------------------------------------------
BIRTH_DATE GENDER
---------- ------------------------------
   300
H
null       MALE


1 row selected.

SQL>
SQL>
SQL> drop table employee;

Table dropped.








4.7.Insert Select
4.7.1.Insert into select
4.7.2.Insert into select with where clause
4.7.3.Insert bulk by insert ... into ... select