Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to insert 300 recordsfrom one table into another

Status
Not open for further replies.

newbieDev

Programmer
Jun 11, 2007
38
US
Hello,

I have been having a hard time with this so I decided to ask for help.

I am trying to insert student names from one table to another.

The student name is the primary key in the new table and I have about 300 records.

How do i insert all records at once?

Thanks

NewbieDev
 

Maybe you could use the INSERT statement? [3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
NewbieDev,

Tell us more about your tables:[ul][li]Is the new table in production, or is it under development?[/li][li]What is the purpose of the 300-row extraction? (Creating a "sandbox" table for you to experiment with? Creating a business-required subset? Et cetera?)[/li][li]Are the 300 student records coming from a production table or are they in a test data set?[/li][li]Who is responsible for the design of both the source and the target tables?[/li][li]How many total rows are in the source table?[/li][li]What is the criteria that specifies which 300 rows from your source table will make it into your target table?[/li][/ul]Let us know and we can offer some suggestions.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
A fo ben, bid bont.
 
if it is just to copy data from one table to another and the "other" table has not been created you can just use:

create table other
as select * from originalTable;

or if it is to insert rows into an existing table then it could be a matter of building the insert statements with a sql select, a la

select 'insert into other values (' || a ||', ' || 'b);'
from originalTable;

and then using the output generate to do your inserts.
 
Keeping a name as a primary key? Isn't that going to cause problems in future?
 
Hi,
good catch dstxaix , using a name as a PK will almost always cause a problem...I am originally from Minnesota and, in our company alone at one time period, we had 6 Richard Petersons ( 4 had the same middle initial and 2 of those the same middle name)




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Newbie said:
I decided to ask for help.
So, we are all lined up to help, but you seemed to have disappeared? What happened to you? Please help us to help you...or just tell us that you no longer need our help. <smile>

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
A fo ben, bid bont.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top