Friday, January 25, 2008

 

Stupid PL/SQL tricks

I needed to load a a few gigs of test data into an Oracle tablespace. Sadly there really aren't any tools for the task. I created a simple table with two columns: id (integer, which apparently is an alias for number(38)) and data (char(512)). PL/SQL code blocks are a little bit more formal than most SQL variants:
DECLARE
i NUMBER;
BEGIN
for i in 1..10000000 loop
insert into sys.t1 values(i,'ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ABCDEFGHI ');
end loop;
END;
Other notes: Every user has a schema. Users are granted permissions to create objects in tablespaces via quotas (although most god roles bypass quota checks). To see if archive logs are enabled, use ARCHIVE LOG LIST;.

Comments: Post a Comment

Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?