Convert size in bytes in human readable size unit

11.2.0.2 RDBMS

Hi all

Is there any function on Oracle to convert bytes into human readable?

Give a number in bytes, that this number is converted in kilobytes or megabytes the gigabytes and so on.

Thank you guys.

CREATE THE FUNCTION HDATA_SIZE)

p_bytes in NUMBERS

p_decimal IN DEFAULT NUMBER 0)

RETURN VARCHAR2

AS

HBYTES VARCHAR2 (80);

BEGIN

HBYTES: = BOX

WHEN p_bytes BETWEEN 0 AND 1023 CAN p_bytes | "Bytes

WHEN p_bytes< power(1024,2)="" then="" round(p_bytes="" 1024,p_decimal)="" ||'="">

WHEN p_bytes< power(1024,3)="" then="" round(p_bytes="" power(1024,2),p_decimal)="" ||'="">

WHEN p_bytes< power(1024,4)="" then="" round(p_bytes="" power(1024,3),p_decimal)="" ||'="">

WHEN p_bytes< power(1024,5)="" then="" round(p_bytes="" power(1024,4),p_decimal)="" ||'="">

WHEN p_bytes< power(1024,6)="" then="" round(p_bytes="" power(1024,5),p_decimal)="" ||'="">

WHEN p_bytes< power(1024,7)="" then="" round(p_bytes="" power(1024,6),p_decimal)="" ||'="">

WHEN p_bytes< power(1024,8)="" then="" round(p_bytes="" power(1024,7),p_decimal)="" ||'="">

WHEN p_bytes< power(1024,9)="" then="" round(p_bytes="" power(1024,8),p_decimal)="" ||'="">

ON THE OTHER

"Invalid value for bytes.

END;

RETURN HBYTES;

END;

SELECT BYTES,

CASE

WHEN BETWEEN 0 AND 1023 BYTES CAN p_bytes | "Bytes

WHEN BYTES< power(1024,2)="" then="" round(bytes="" 1024,2)="" ||'="">

WHEN BYTES< power(1024,3)="" then="" round(bytes="" power(1024,2),2)="" ||'="">

WHEN BYTES< power(1024,4)="" then="" round(bytes="" power(1024,3),2)="" ||'="">

WHEN BYTES< power(1024,5)="" then="" round(bytes="" power(1024,4),2)="" ||'="">

WHEN BYTES< power(1024,6)="" then="" round(bytes="" power(1024,5),2)="" ||'="">

WHEN BYTES< power(1024,7)="" then="" round(bytes="" power(1024,6),2)="" ||'="">

WHEN BYTES< power(1024,8)="" then="" round(bytes="" power(1024,7),2)="" ||'="">

WHEN BYTES< power(1024,9)="" then="" round(bytes="" power(1024,8),2)="" ||'="">

ON THE OTHER

"Invalid value for bytes.

END;

HUMAN_SIZE,

HDATA_SIZE (BYTES) FUNC_BYTES,

HDATA_SIZE(BYTES,2) FUNC_BYTES_ROUND_2

OF BYTES_CONVERSION;

"BYTES." 'HUMAN_SIZE '. 'FUNC_BYTES '. 'FUNC_BYTES_ROUND_2 '.
48743068764242424 "43,29 PB" "PB 43. "43,29 PB"
2052456451442442 "PB OF 1.82. "2 PB. "PB OF 1.82.
1456842042452424 "PB OF 1.29. "1 PB. "PB OF 1.29.
140018974724255 "127,35 TB" "127 TB" "127,35 TB"
1380345446444 "1.26 TB" "1 TB. "1.26 TB"
11682705691 "10,88 GB" "11-GO" "10,88 GB"
9419054298 "8,77 GB" '9 GB' "8,77 GB"
4928925707 "4.59 GB" "5 GB" "4.59 GB"
4734365808 "4.41 GB" "4 GB" "4.41 GB"
2996172607 "2.79 GB" "3 GB" "2.79 GB"
2996161255 "2.79 GB" "3 GB" "2.79 GB"
2239299702 "2.09 GB" "2 GB" "2.09 GB"
2239294829 "2.09 GB" "2 GB" "2.09 GB"
1092878347 "1.02 GB" "1 GB". "1.02 GB"
1034780683 "986,84 MB" "987 MB" "986,84 MB"
902561803 "860,75 MB" "861 MB" "860,75 MB"
710223170 "677,32 MB" "677 MB" "677,32 MB"
700729988 "668,27 MB" "668 MB" "668,27 MB"
700598916 "668,14 MB" "668 MB" "668,14 MB"
631504907 "602,25 MB" "602 MB" "602,25 MB"

Editada por Mensagem: bytes-13728488

Tags: Database

Similar Questions

  • How to convert a single byte String?

    Purpose:

    Show a result byte on the BB 9900 screen.

    Question:

    How to convert a single byte String?

    Part of the code:

    byte value = con.cpu_config.elementAt (i)

    stop here

    String valuestring = new String (value);

    _rtf. SetText (valueString);

    If you know how to fix it, please share your idea.

    Thank you for your attention,

    String valuestring = new String (new byte [] {value}};)

    _data. Append (valueString);

    _rtf. SetText (_data.toSrting ());

    Solve it.

  • First Pro CC project files human readable XMLs not more?

    Hey,.

    in CS6 proproj-projects were XMLs which you could analyze and understand, so we have written some tools to be able to change the names of files etc. on the fly. CC files appear as binary garbage now, looks like they're not human readable anymore. We do something wrong? Why change something like that without announce it when this you as a feature only a few versions before?

    Thank you!

    Steffen

    http://forums.Adobe.com/message/5543833#5543833

  • Why to convert all versions of converter size disc with decimals?

    If you can convert a VM of 20 GB say 30 GB shows that 30.029238383 GB size in the size of the disk when you change the settings of the virtual machine.

    Anyone know why this is? They cannot convert integers alone?

    Many thanks,

    The disk size is approximate. The computation of the exact size of the disk, the converter takes into account several considerations such as partition alignment, cluster size that can be changed, the dynamic volumes being converted to base, start the partitions, metadada. (I say not all affect the size of the disk, emphasizing that it is not as simple)

    Concerning

    Plamen

  • How do I convert JAXBElement &lt; byte [] &gt; string or readable format

    Hi Experts,

    I work on the web service proxy and I want to retrieve data from JAXBElement < byte [] > data type and add data to the table. I have tried with...

    Note_c1 JAXBElement < byte [] > = ((RequestEntryC) optyBind) .getNoteC ();

    String Note_c = Arrays.toString (Note_c1.getValue ());

    But it returns [115, 117, 105, 116, 101, 32, 118, 105] , and [B@27e80064 if I try with Note_c1.getValue () ]


    I'm on Jdeveloper 11.1.1.7.1



    User, you bet a byte of the Note_c1 array. You can convert this string as

    String s = new String (Note_c1.getValue ());

    However it is not guaranteed that you can read the string. Only if the bytes represent characters ASCII or UTF-8 you can read.

    Timo

  • Convert hex (or byte?) duplicate

    Hallo,

    I'm contacting an instrument through VISA controls.

    I'm getting a release in the hexagonal form combination of numbers and letters.

    the thing is that, with all the formulas that I tried to convert it to a double I failed miserably.

    The data card, you gave me, I thought that the following Hexagon should have the corresponding values:

    C5D1 (2 octets)-> 26

    THIS EF5D of CA (4-byte)-> 957

    C4E2 (2bytes)-> 14

    Instead, I get a very large number.

    could you please tell me how to convert these duplicate?

    Thank you in advance,

    Thodoros


  • How to convert hex 8 bytes floating point double?

    Hello

    I want to know how to convert a string of 8 bytes of data double floating-point.

    data (HEX): 40 02 70 40 00 00 00 4F

    Thank you.

    DP

    This string of 8 bytes of data is actually a string? Are the characters in the string of letters or you have hex values? Ultimately you want to use the Type Cast:

  • Convert Int to byte array.

    Hello

    I am trying to convert an int to an array of bytes and stumbled upon a solution. However, it is not appropriate for BB/J2ME.

    byte[] bytes = ByteBuffer.allocate(4).putInt(1695609641).array();
    
    for (byte b : bytes) {
       System.out.format("0x%x ", b);
    }
    

    I have converted into loop, but not an alternative to System.out.format () there is no J2ME.

    How can I convert my whole in byte array?

    Thank you.

    Hi guys, sorry for the delay in responding. Basically, I have to send my ACR122U an int on NFC. If int is more than 255 does not in a single byte then I have to represent in an array of bytes, right?

    I think RexDoug is correct also, I don't understand masking and stuff like that. It's something that I've always been conscious of good :/

    Thank you guys.

    Here's what I went with:

      public byte[] intToBytes(int value) {
    
             return new byte[] {
                        (byte) ((value >>> 24) & 0xff),
                        (byte) ((value >>> 16) & 0xff),
                        (byte) ((value >>> 8) & 0xff),
                        (byte) (value & 0xff),
                      };
        }
    

    REF: http://stackoverflow.com/questions/9587605/java-integer-to-byte-array-blackberry-j2me/9587708#958770...

  • Convert InputStream into byte array

    Hey everybody,

    I really need help with this problem that I can not get rid! I am doing an application that loads an image saved on the BB device and sends it to a server, the problem is we can send only a byte [].

    So I try to apply the following method:

    -Loading the image via the FileConnection class

    -Open an InputStream from the FileConnection said

    -Convert an array of bytes as InputStream

    The code should look like this I guess:

    FileConnection file = (FileConnection) Connector.open ("Original_SealV.jpg");
    InputStream is = file.openInputStream ();

    Byte [] img = null;
    int temp = is.read ();
    {while(Temp>0)}

    Convert bytes here?

    }

    This is the last step I'm missing, I tried several methods, but could not run, so I beg for a bit of the collective wisdom of these forums...

    Could someone help me? I will not forget the congratulations!

    or you can always use the standard API

    Byte [] buf = IOUtilities.streamToBytes (stream);

  • How to convert a single byte in UTF8 characters

    Hello
    I have problem with the export of data to the file with UTF8 encoding.

    I varchar2 columns in the database with NLS_CHARACTERSET = EE8ISO8859P2 (Czech Republic) and I need to export the columns in the file with UTF8 encoding.

    So I need to make a single byte FOR byte conversion multi.

    I tried sql CONVERT (CONVERT ('my_char', 'UTF8') command) in the forms, but without effect. The encoding of the file created is UTF8, but the characters are corupted.

    Registry settings on my client is NLS_LANG = REPUBLIC of AMERICAN_CZECH. EE8MSWIN1250

    Could you tell me some thing how to export data from the column with characters on a single byte of file with UTF8 encoding?

    I use Text_io package to write in the shapefile.

    Thank you

    my last try so if you can afford an empty space in your output file in the fist line. I tested hv it works

    create a foo.txt with empty space and then add the file as a normal procedure or try to re - open the file later and replace the space in the first row using SUBSTR etc etc.

    TEXT_IO has very limited functionality try to package DDE it might solve your problem

    Good luck
    Bangoura

  • BlackBerry Smartphones how can I convert save the file into something readable!

    Using the Desktop Manager that I created a .ipd backup file.

    Now... How can I convert these data into something I can easily recognize?

    Oops - I forgot that the app... JSanders thanks!

  • PDF files mysteriously converted to the word without human interface!

    I woke up this morning my computer to find that ALL my PDF files have mysteriously been converted into Word documents - others are just not there at all.  I can't convert Word to PDF.  As much as I know I haven't all the parameters that would entail.   I am also getting notes "check with the administrator.  I rebooted, I tried a system restore, and I deleted and reloaded Adobe 9.3 I can now see documents PDF if I drop them in the Adobe box on my desk, however when I try to save them, continue to be registered as Word.  Can someone help me?  Please...

    The method is similar in different operating systems, but the differences are small. Basically, you right (click with the right button of your mouse), click the icon of one of the files you know there must be a PDF file, choose Properties in the new window. In general, then click on the button of change with eyes Open with, choose the Player in the popdown menu. Be sure to check the always use this program for files of this type. Please note that the texts my different being that my Windows is in Spanish and I have written are the translations of what I see on my screen.

  • How to change e-mail entrants (in outlook express 2002) in human-readable format?

    Express Outlook 2002 in Windows 7, e-mails are all alphabetic characters and unreadlable.  How/where to change the settings.

    You see data BASE64 that represents the content of the message.  If you use Outlook 2002 or Outlook Express 6, the most likely cause of your symptoms scans mail entering with an antivirus program.  Completely uninstall your AV program and reinstall without any mail analysis feature. Brian Tillman [MVP-Outlook]
    --------------------------------
    https://MVP.support.Microsoft.com/profile/Brian.Tillman
    If a response may help, please vote it as useful. If a response to the problem, please mark it as an answer.

  • Tool to display the configuration of VMware ESX in a human readable form

    Hello

    I'm looking for a tool to display our configuration of our vSphere hosts.

    Is there a tool available (perhaps thirdparty)?

    Kind regards

    Roland

    If no "hostprofiles" use this https://labs.vmware.com/flings/inventorysnapshot.

    With this tool you can do too much extract configurations and reproduce the same return.

    ~ dGeorgey

  • video converter to play the video in the central unit of car stereo sony xav 63

    Hello

    I'm not able to play the video in sony xav 63, please can you suggest some video converter I downloaded a video converter, but it does not come when I tried with the device in my car.

    Thank you

    Josiane

    Hello saasmi,

    And good afternoon! I noticed that you said in your post ' I downloaded a video converter, but it does not come when I tried with the device in my car. " Can I ask you which device you want to use to get the sound working on your AV Center?

Maybe you are looking for