25 февраля 2011 г.

oracle: insert

Примеры

1. oracle: insert как select из другой таблицы

2. insert with select


insert into t values('ANDROID',(select round(avg(user_id)) from t),sysdate);




3. Examples

Inserting Values into Tables: Examples The following statement inserts a row into the sample table departments:
INSERT INTO departments
   VALUES (280, 'Recreation', 121, 1700);

If the departments table had been created with a default value of 121 for the manager_id column, then you could issue the same statement as follows:
INSERT INTO departments
   VALUES (280, 'Recreation', DEFAULT, 1700);

The following statement inserts a row with six columns into the employees table. One of these columns is assigned NULL and another is assigned a number in scientific notation:
INSERT INTO employees (employee_id, last_name, email, 
      hire_date, job_id, salary, commission_pct) 
   VALUES (207, 'Gregory', 'pgregory@example.com', 
      sysdate, 'PU_CLERK', 1.2E3, NULL);

The following statement has the same effect as the preceding example, but uses a subquery in the DML_table_expression_clause:
INSERT INTO 
   (SELECT employee_id, last_name, email, hire_date, job_id, 
      salary, commission_pct FROM employees) 
   VALUES (207, 'Gregory', 'pgregory@example.com', 
      sysdate, 'PU_CLERK', 1.2E3, NULL);