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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating a million row based on existing table

Status
Not open for further replies.

dbalearner

Technical User
Aug 23, 2003
170
GB
I have a table t that I created as follows:

CREATE TABLE T
AS
(
SELECT
a.*
,RPAD('*',4000,'*') AS PADDING1
,RPAD('*',4000,'*') AS PADDING2
FROM ALL_OBJECTS a
)
ORDER BY dbms_random.random;
ALTER TABLE T ADD CONSTRAINT T_PK PRIMARY KEY (object_id);

this table has around 70,000 rows with OBJECT_ID as the primary key.

I would like to create a new table t2 that will have a million rows based upon rows on table t. This is for test purposes.

However, object_id in the new table has to be unique. Can I create incrementing object_id values based upon max(object_id) from table t. An option that comes to my mind is using a sequence. Are there betterr ways of doing this?

Thanks
 
I think a sequence is an excellent approach - especially if you use a high cache value on it.
 
Assuming the object_id's in the two tables don't need to tie in with each other you could do a few insert into t2 select * from t until you get your million+ records. Next update t2 set object_id = rownum


In order to understand recursion, you must first understand recursion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top