Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
Function to compress text, not encrypt

Function to compress text, not encrypt

2004-03-15       - By Tim Gorman

Reply:     1     2     3     4     5     6     7     8     9     10  

Juan Cachito,

It is more space-efficient to simply store numeric values in a NUMBER
datatype instead of text. Of course, it is not so apparent with short
values like 11 and ?11?...

> SQL > select dump(11) from dual;
>
> DUMP(11)
> -- ---- ---- ------
> Typ=2 Len=2: 193,12
>
> SQL > select dump( '11 ') from dual;
>
> DUMP( '11 ')
> -- ---- ---- ------
> Typ=96 Len=2: 49,49

They both consume 2 bytes here so that represents 0% compression, but now
let?s try numbers with more significant digits:

> SQL > select dump(1111) from dual;
>
> DUMP(1111)
> -- ---- ---- ---- ----
> Typ=2 Len=3: 194,12,12
>
> SQL > select dump( '1111 ') from dual;
>
> DUMP( '1111 ')
> -- ---- ---- ---- ---- --
> Typ=96 Len=4: 49,49,49,49

Four bytes to store it as a character string, but only three bytes needed to
store it as a NUMBER datatype, so that?s 33% ?compression?. If we keep this
up...

> SQL > select dump (111111) from dual;
>
> DUMP(111111)
> -- ---- ---- ---- ---- --
> Typ=2 Len=4: 195,12,12,12
>
> SQL > select dump( '111111 ') from dual;
>
> DUMP( '111111 ')
> -- ---- ---- ---- ---- ---- ---
> Typ=96 Len=6: 49,49,49,49,49,49

Four bytes instead of six ? that?s 50% ?compression?...

> SQL > select dump(11111111) from dual;
>
> DUMP(11111111)
> -- ---- ---- ---- ---- -----
> Typ=2 Len=5: 196,12,12,12,12
>
> SQL > select dump( '11111111 ') from dual;
>
> DUMP( '11111111 ')
> -- ---- ---- ---- ---- ---- ---- ----
> Typ=96 Len=8: 49,49,49,49,49,49,49,49

Five bytes instead of eight; that represents a 60% compression ratio...

> SQL > select dump(1111111111) from dual;
>
> DUMP(1111111111)
> -- ---- ---- ---- ---- ---- ---
> Typ=2 Len=6: 197,12,12,12,12,12
>
> SQL > select dump( '1111111111 ') from dual;
>
> DUMP( '1111111111 ')
> -- ---- ---- ---- ---- ---- ---- ---- ------
> Typ=96 Len=10: 49,49,49,49,49,49,49,49,49,49

Six bytes instead of ten; that is a 66% compression ratio. For numeric
text values, you can count on (N/2)+1 where ?N? is the number of significant
decimal digits. And, you can do a whole lot better when you?re dealing with
lots of zeroes...

> SQL > select dump(10000000000) from dual;
>
> DUMP(10000000000)
> -- ---- ---- -----
> Typ=2 Len=2: 198,2
>
> SQL > select dump( '10000000000 ') from dual;
>
> DUMP( '10000000000 ')
> -- ---- ---- ---- ---- ---- ---- ---- ---- ----
> Typ=96 Len=11: 49,48,48,48,48,48,48,48,48,48,48
>
Hoo-wee! That?s about 450% compression ratio, I think...

Hope this helps...

-Tim


on 3/12/04 1:14 PM, Juan Cachito Reyes Pacheco at jreyes@(protected)
wrote:

> Hi, is there a function to compress test
> for example 11 you can compress to K (11th letter).
> to optimize storage in data rarely queried.
>
> Thanks
>
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> To unsubscribe send email to: oracle-l-request@(protected)
> put 'unsubscribe ' in the subject line.
> --
> Archives are at http://www.freelists.org/archives/oracle-l/
> FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --


<HTML >
<HEAD >
<TITLE >Re: Function to compress text, not encrypt </TITLE >
</HEAD >
<BODY >
<FONT FACE= "Arial " > <SPAN STYLE= 'font-size:12.0px ' >Juan Cachito, <BR >
<BR >
It is more space-efficient to simply store numeric values in a NUMBER datatype instead of text.  Of course, it is not so apparent with short values like 11 and “11”... <BR >
<BR >
</SPAN > </FONT > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(11) from dual; <BR >
<BR >
DUMP(11) <BR >
-- ---- ---- ------ <BR >
Typ=2 Len=2: 193,12 <BR >
<BR >
SQL> select dump( '11 ') from dual; <BR >
<BR >
DUMP( '11 ') <BR >
-- ---- ---- ------ <BR >
Typ=96 Len=2: 49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
They both consume 2 bytes here so that represents 0% compression, but now let’s try numbers with more significant digits: <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(1111) from dual; <BR >
<BR >
DUMP(1111) <BR >
-- ---- ---- ---- ---- <BR >
Typ=2 Len=3: 194,12,12 <BR >
<BR >
SQL> select dump( '1111 ') from dual; <BR >
<BR >
DUMP( '1111 ') <BR >
-- ---- ---- ---- ---- -- <BR >
Typ=96 Len=4: 49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Four bytes to store it as a character string, but only three bytes needed to store it as a NUMBER datatype, so that’s 33% “compression”.  If we keep this up... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump (111111) from dual; <BR >
<BR >
DUMP(111111) <BR >
-- ---- ---- ---- ---- -- <BR >
Typ=2 Len=4: 195,12,12,12 <BR >
<BR >
SQL> select dump( '111111 ') from dual; <BR >
<BR >
DUMP( '111111 ') <BR >
-- ---- ---- ---- ---- ---- --- <BR >
Typ=96 Len=6: 49,49,49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Four bytes instead of six — that’s 50% “compression”... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(11111111) from dual; <BR >
<BR >
DUMP(11111111) <BR >
-- ---- ---- ---- ---- ----- <BR >
Typ=2 Len=5: 196,12,12,12,12 <BR >
<BR >
SQL> select dump( '11111111 ') from dual; <BR >
<BR >
DUMP( '11111111 ') <BR >
-- ---- ---- ---- ---- ---- ---- ---- <BR >
Typ=96 Len=8: 49,49,49,49,49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Five bytes instead of eight; that represents a 60% compression ratio... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(1111111111) from dual; <BR >
<BR >
DUMP(1111111111) <BR >
-- ---- ---- ---- ---- ---- --- <BR >
Typ=2 Len=6: 197,12,12,12,12,12 <BR >
<BR >
SQL> select dump( '1111111111 ') from dual; <BR >
<BR >
DUMP( '1111111111 ') <BR >
-- ---- ---- ---- ---- ---- ---- ---- ------ <BR >
Typ=96 Len=10: 49,49,49,49,49,49,49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Six bytes instead of ten;  that is a 66% compression ratio.  For numeric text values, you can count on (N/2)+1 where “N” is the number of significant decimal digits.  And, you can do a whole lot better when you’re dealing with lots of zeroes... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(10000000000) from dual; <BR >
<BR >
DUMP(10000000000) <BR >
-- ---- ---- ----- <BR >
Typ=2 Len=2: 198,2 <BR >
<BR >
SQL> select dump( '10000000000 ') from dual; <BR >
<BR >
DUMP( '10000000000 ') <BR >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- <BR >
Typ=96 Len=11: 49,48,48,48,48,48,48,48,48,48,48 <BR >
</FONT > <FONT FACE= "Arial " > <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " >Hoo-wee!  That’s about 450% compression ratio, I think... <BR >
<BR >
Hope this helps... <BR >
<BR >
-Tim <BR >
<BR >
<BR >
on 3/12/04 1:14 PM, Juan Cachito Reyes Pacheco at jreyes@(protected) wrote: <BR >
<BR >
<FONT COLOR= "#000098 " >> Hi, is there a function to compress test <BR >
> for example 11 you can compress to K (11th letter). <BR >
> to optimize storage in data rarely queried. <BR >
> <BR >
> Thanks <BR >
> <BR >
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ <BR >
> Please see the official ORACLE-L FAQ: <a href= "http://www.orafaq.com " >http://www.orafaq.com </a > <BR >
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ <BR >
> To unsubscribe send email to:  oracle-l-request@(protected) <BR >
> put 'unsubscribe ' in the subject line. <BR >
> -- <BR >
> Archives are at <a href= "http://www.freelists.org/archives/oracle-l/ " >http://www.freelists.org/archives/oracle-l/ </a > <BR >
> FAQ is at <a href= "http://www.freelists.org/help/fom-serve/cache/1.html " >http://www.freelists.org/help/fom-serve/cache/1.html </a > <BR >
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- <BR >
</FONT > </FONT > </SPAN >
</BODY >
</HTML >