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

Teradata question insert

Status
Not open for further replies.

SL23

Programmer
Nov 3, 2005
12
Hi,

I have this script in oracle,
begin
for i in 1..100000 loop
INSERT INTO STUDENT VALUES (i,'FirstName','LastName','Major' ,55000,'2006-06-05');
commit;
end loop;
end;

Can some one help me to write this in teradata.

the table is
create table student
, no fallback
, no before journal
, no after journal
(
student_number integer not null,
first_name varchar (30),
last_name varchar (30),
department varchar (30),
student_loan_amount decimal (10,2),
expected_graduation date format 'yyyy-mm-dd' not null
)
primary index PK_student (student_number)
 
Hi,
With teradata you want to do everything in SETS. Here I

populate a table with 10 rows

create a table with 1 million rows by a cartesion product of the first table and your constants.


Code:
ct numbers, no fallback ( k integer )
   unique primary index(k);


insert into numbers VALUES(0);
insert into numbers VALUES(1);
insert into numbers VALUES(2);
insert into numbers VALUES(3);
insert into numbers VALUES(4);
insert into numbers VALUES(5);
insert into numbers VALUES(6);
insert into numbers VALUES(7);
insert into numbers VALUES(8);
insert into numbers VALUES(9);


INSERT INTO STUDENT 
   sel 1+ a.k +
       ( b.k * 10 ) +
       ( c.k * 100 ) +
       ( d.k * 1000 ) +
       ( e.k * 10000 ) +
       ( f.k * 100000 ),
'FirstName','LastName','Major'  ,55000,'2006-06-05'
   from numbers a,
        numbers b,
        numbers c,
        numbers d,
        numbers e,
        numbers f ;

 
In oracle the table valuse looks like this:
"1","FirstName","LastName","Major","55000","05/31/2006"
"2","FirstName","LastName","Major","55000","05/31/2006"
"3","FirstName","LastName","Major","55000","05/31/2006"
"4","FirstName","LastName","Major","55000","05/31/2006"
"5","FirstName","LastName","Major","55000","05/31/2006"
"6","FirstName","LastName","Major","55000","05/31/2006"
"7","FirstName","LastName","Major","55000","05/31/2006"
"8","FirstName","LastName","Major","55000","05/31/2006"
"9","FirstName","LastName","Major","55000","05/31/2006"
"10","FirstName","LastName","Major","55000","05/31/2006"

When I do the insert. Will it be the same in teradata, I am very new to this...
Help me please....
 
IT WORKS PERFACT, TDATGOD

THANKS!
 
Question:

I am using two table to populate odd numbers(tbl1) and even numbers (tbl2).
and loading the data in to tbl3.

I want to run both the queries at the same time.

When start the two queries, it is not populating the data. If I run one query it loads data.
Is that any way I can run both queries and populate in one table in teradata.

It looks like when I run the query it locks the table....
 



Can you post your queries? maybe you can simply UNION your 2 queries together.


insert into mytable
( select * from evens
union all
select * from odds
) ;

The ALL on the union tells it not to eliminate duplicates. Since I know the tables don't overlap I can save a little time not doing the duplicate checking.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top