Hey,
Is there any reason to use the BINARY and VARBINARY data types instead of CHAR and VARCHAR? They all store up to 65,000 bytes so I don't understand the difference between them.
BINARY/VARBINARY vs. CHAR/VARCHAR
Moderator: NorbertKrupa
-
- Intermediate
- Posts: 96
- Joined: Thu Jul 19, 2012 12:33 am
BINARY/VARBINARY vs. CHAR/VARCHAR
Thanks,
Harry
Harry
Re: BINARY/VARBINARY vs. CHAR/VARCHAR
Hi!
How you will store binary data(images for example)? As CHAR/VARCHAR? There are some compatibility between char and binary for text/letters (strings are stored as binary data on a bottom layer), that why it's doesn't matter for strings, but matter for binary data. Binary data can be printed as text (with hexdump for example) or can be executed by OS.
Binary data (can be printed or executed):
How you will store binary data(images for example)? As CHAR/VARCHAR? There are some compatibility between char and binary for text/letters (strings are stored as binary data on a bottom layer), that why it's doesn't matter for strings, but matter for binary data. Binary data can be printed as text (with hexdump for example) or can be executed by OS.
Binary data (can be printed or executed):
Code: Select all
$ file /bin/cp
cp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x1f9374eeb4ce33dbe93ff8fb933700a898e4346a, stripped
Code: Select all
$ hexdump -C /bin/cp | head -5
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 3e 00 01 00 00 00 10 34 40 00 00 00 00 00 |..>......4@.....|
00000020 40 00 00 00 00 00 00 00 68 e5 01 00 00 00 00 00 |@.......h.......|
00000030 00 00 00 00 40 00 38 00 09 00 40 00 1c 00 1b 00 |....@.8...@.....|
00000040 06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00 |........@.......|