Try Another
A project is about to get underway. You know that the project ID is P434 and that its name is Mass Media Campaign Blitz.
Insert a row into the PROJECT table giving this information. The PROJ_ID and PROJ_DESC columns contain character data.
Confirm the insertion. To check your answers, see Review Answers for Chapter 8.
The result looks like this:
PROJ_ID PROJ_DESC ------- --------- C200 New brand research C203 Consumer study C240 Service study P400 Christmas media P434 Mass Media Campaign Blitz P634 TV ads - WTVK D880 Systems analysis 7 rows processed
Inserting rows with SELECT
You can copy selected rows from one table and put them into another table using the SELECT statement within the INSERT statement. A SELECT statement in an INSERT statement is referred to as a query specification.
Include a WHERE clause in the SELECT statement to insert only those rows meeting the search condition.
How It's Done
Your company has decided to hire one of the consultants, 9388, as a full-time employee. To add the employee information from the CONSULTANT table into the ASSIGNMENT table, enter:
insert into assignment (emp_id, proj_id, start_date)
select con_id, proj_id, start_date
from consultant
where con_id = 9388;
The columns in the receiving table must have data compatible with the data of the corresponding columns in the sending table.
You can use SELECT * if you are using all columns in the same order as in the table to which you are adding the row.
Enter a SELECT statement to display the table and confirm the insertion.
The result looks like this:
EMP_ID PROJ_ID START_DATE END_DATE ------ ------- ---------- -------- 2894 P634 2000-02-15 <null> 3411 P634 2000-03-01 <null> 4358 C240 1998-06-01 1998-08-15 2466 D880 1999-11-01 <null> 9388 D880 1997-12-21 <null> 5 rows processed
|
Copyright © 2014 CA.
All rights reserved.
|
|