jes | Sat, 23 Feb 2008 13:21:00 GMT |
ian | Sat, 23 Feb 2008 13:22:00 GMT |
jes | Sat, 23 Feb 2008 13:23:00 GMT |
ian | Sat, 23 Feb 2008 13:24:00 GMT |
On my laptop I copied a dictionary file into the /tmp directory to use as an example text file
[jes...powerbook tmp]$ cp /usr/share/dict/propernames data.txt
check the size of the uncompressed text file
[jes...powerbook tmp]$ ls -al data.txt
-r--r--r-- 1 jes wheel 8640 Aug 30 14:30 data.txt
show the first few lines of the file
[jes...powerbook tmp]$ head data.txt
Aaron
Adam
Adlai
Adrian
Agatha
Ahmed
Ahmet
Aimee
Amy
Ami
check what type of file the OS thinks it is
[jes...powerbook tmp]$ file data.txt
data.txt: ASCII English text
Create a table to store the blob
jes...10gR2> create table blob_files (id int primary key, data blob);
Table created.
Create the directory to be used with the bfile loading
jes...10gR2> create or replace directory file_dir as '/tmp';
Directory created.
1 declare
2 l_blob blob;
3 l_compressed_blob blob;
4 l_buffer RAW(32767);
5 l_amount BINARY_INTEGER := 32767;
6 l_pos INTEGER := 1;
7 l_blob_length INTEGER;
8 l_bfile bfile;
9 l_output_file UTL_FILE.FILE_TYPE;
10 begin
11 -- insert a record into the blob_files table and return back the empty blobs
12 insert into blob_files values (1, empty_blob(), empty_blob() )
returning data, compressed_data into l_blob, l_compressed_blob;
13 -- bfile pointer to the file on the filesystem
14 l_bfile := bfilename( 'FILE_DIR', 'data.txt' );
15 -- open the bfile and load it into l_blob
16 dbms_lob.fileopen(l_bfile );
17 dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength( l_bfile ) );
18 dbms_lob.fileclose(l_bfile );
19 -- compress the blob
20 UTL_COMPRESS.lz_compress (src => l_blob, dst => l_compressed_blob);
21 -- pointer to our output file on the filesystem
22 l_output_file := UTL_FILE.fopen('FILE_DIR', 'data.zip', 'wb', 32767);
23 -- grab the length of the compressed blob
24 l_blob_length := DBMS_LOB.getlength(l_compressed_blob);
25 -- loop round the compressed blob and output it to the file
26 while l_pos <
l_blob_length LOOP
27 DBMS_LOB.read(l_compressed_blob, l_amount, l_pos, l_buffer);
28 UTL_FILE.put_raw(l_output_file, l_buffer, TRUE);
29 utl_file.fflush(l_output_file);
30 l_pos := l_pos + l_amount;
31 END LOOP;
32 -- flush the output and close the file
33 utl_file.fflush(l_output_file);
34 UTL_FILE.fclose(l_output_file);
35* end;
36 /
PL/SQL procedure successfully completed.
Compare the sizes of the data
1* select dbms_lob.getlength(data) original_length,
dbms_lob.getlength(compressed_data) compressed_length
from blob_files
ORIGINAL_LENGTH COMPRESSED_LENGTH
-- --
8640 3926
Back in the filesystem, check the zipfile has been created
[jes...powerbook tmp]$ ls -al data*
-r--r--r-- 1 jes wheel 8640 Aug 30 14:30 data.txt
-rw-r--r-- 1 oracle wheel 3926 Aug 30 14:31 data.zip
OS recognises it as a zipfile
[jes...powerbook tmp]$ file data.zip
data.zip: gzip compressed data, from Unix
It's definitely a zipfile
[jes...powerbook tmp]$ gzip -l data.zip
compressed uncompressed ratio uncompressed_name
3926 8640 54.8% data.zip
copy the zipfile to use the 'gz' suffix to make it work with gunzip easier
[jes...powerbook tmp]$ cp data.zip test.gz
[jes...powerbook tmp]$ gunzip test.gz
confirm the contents are still the same as the original file
[jes...powerbook tmp]$ head test
Aaron
Adam
Adlai
Adrian
Agatha
Ahmed
Ahmet
Aimee
Amy
Ami
jes | Sat, 23 Feb 2008 13:25:00 GMT |
ian | Sat, 23 Feb 2008 13:26:00 GMT |
jes | Sat, 23 Feb 2008 13:27:00 GMT |
johnvaughan | Sat, 23 Feb 2008 13:28:00 GMT |
ian | Sat, 23 Feb 2008 13:29:00 GMT |
Does anyone know of any software that could convert a US Zipcode into an X/Y Coordinate that I could then load into Oracle Spatial? I'm looking at converting Zipcodes for Tennesse....
Hi,Can any body tell me how to automatically zip export file whe we take backups with export utility.Regards,...
Hello.I use a scedule to backup 3 schemas in a prod db with exp .but because of the size after the creation of the 3 .dmp files ( aprox 500m)i use winrar and compress the 3 files (aprox 50m).my q is .is that accurate? or after recompress and restore i might loose data?ThanksAris_dc....
I want to show the data in a report. Scenario is that i have different companies and for each company there is a sale amount at particular date. It is possible that for some date there is no sales means no data for that company. I have date range as search parameter like 'from date' an...
When a record from my flat-file begins with 0 the 0 is being dropped from the insert using SQLLDR. For example, in the flat file:20031006123456789684012003100609876543268150Starting at position 9 and going to position 17 the data inserted should be 098765432 but the 0 is dropping and I am ending...
ive downloaded over 1 gig of the zip files for oracle9i personal. Both times ive gotten corrupted zip files that wont open. Im not lagging out, or getting bad connection which usually corrupts large downloads. I am using a cable connection and DL'ing it all in around 50 minutes a piece (3 d...
Hii download both zip files. when i click on these zip files, i receive a messeage that "NO ZIP FILE, BAD ZIP FILE OR PART OF A SPANNED/SPLIT ZIP FILE". When i try to extract it again show me error . Please guide me. when i download it , it download very smothly.ThanksAtiq...
I am building a database with a seperate table for Zip Codes, Cities and States. Is there a Built-In or some other resource for building such a table with all USA Codes?Thanks in advance.Bruce Hyatt...
I produce large text files from pl/sql packages on Oracle 8i, using utl_file. I would like to zip these files after producing them, in the same pl/sql procedure.How can I do it?...
I am experiencing something that goes over my knowledge. We have done database testing for both ZHT16BIG5 and western char set in Oracle 8i. In western char set, no problems. the test goes perfect.With ZHT16BIG5 inserting of the tables fail. Below you'll find the log from the test:Performin...
Hi,I got this question from calling trim(source) on an empty string. Just wondering why Oracle thinks zero-length String is null? i.e., trim(' ') is null.Thanks!...
hello,I was wondering if anyone knows about a SQL or PL/SQL way of removing the Z values, leaving only X and Y.......
Dear sir,My boss told me to go for PARALLEL SERVER OPTION.Please tell me where will I get 1) The complete installation procedure. 2) The complete hardware required for it. 3) Budget required.Is there any link available.Q) What benefits will I be reaping if I register myself onto the METALINK.One...
Hello!Can anybody help me??I'm uploading images in my data base like in the samle [URL=http://technet.oracle.com/sample_code/products/intermedia/htdocs/sdk_101/webagent.htm.]http://technet.oracle.com/sample_code/products/intermedia/htdocs/sdk_101/webagent.htm.[/URL] I have just one problem,...
Hellow Sir,Please tell me about error 12571. What causes it occur how much hazardous it can proved to me.Some part of trace in UDUMP, I am enclosing*** 2002.05.30.18.09.34.545*** SESSION ID:(55.643) 2002.05.30.18.09.34.515FATAL ERROR IN TWO-TASK SERVER: error = 12571*** 2002.05.30.18.09.34.545ks...