Oracle数据库中的字节序格式是什么?

打印 上一主题 下一主题

主题 1048|帖子 1048|积分 3144

前言:本文是对这篇博客What is the endian format in Oracle databases?[1]的翻译,如有翻译不当的地方,敬请谅解,请尊重原创和翻译劳动成果,转载的时候请注明出处。谢谢! 
英文地址:https://dbtut.com/index.php/2019/06/27/what-is-the-endian-format-in-oracle-databases/

什么是字节序?

字节序(Endian)是多字节数据类型在内存中的存储方式。换句话说,它决定了数据的字节顺序。有两种字节序,小字节序(Little Endian)和大字节序(Big Endian)。
小字节序

数据先存储小端。也就是说,第一个字节是最大的。
另外一种翻译:将低序字节存储在起始地址。
大字节序

数据先存储大端。即第一个字节是最小的。
另外一种翻译:高序字节存储在起始地址。
例如:
假设一个整数存储为4个字节(32位),那么一个值为0x01234567(十进制表示)的变量将以0x01、0x23、0x45、0x67的形式存储。在具有大端的系统中,此数据按此顺序存储,而在小端系统中,它以相反的顺序存储。
Little Endian 和 Big Endian 的区别

下图显示了大端和小端的区别。
在 Oracle 数据库中,字节序格式由其工作环境中的字节序信息决定。数据库中的字节序格式告诉我们相关数据库可以移动到哪些环境。在不同的端序环境之间使用常规方法移动数据库是不可能的。例如,您不能用Data Guard 将数据库从 Little Endian系统传输到具有Big Endian的系统。
您可以用以下SQL查看数据库中的当前字节序格式。
  1. SQL> select name,platform_id,platform_name from v$database;<br> <br>NAME      PLATFORM_ID PLATFORM_NAME<br>--------- ----------- ----------------------------------------------------------<br>ORCL         13       Linux x86 64-bit<br>
复制代码
以下查询显示了可以移动现有数据库的其他环境。
大端格式 (IBM AIX)
  1. SQL> set lines 200<br>SQL> set pages 200<br>SQL> COL "Source" FORM a32<br>SQL> COL "Compatible Targets" FORM a40<br>SQL> select d.platform_name "Source", t.platform_name "Compatible Targets", endian_format<br>from v$transportable_platform t, v$database d where t.endian_format = (select endian_format from v$transportable_platform t, v$database d where d.platform_name = t.platform_name) <br>order by "Compatible Targets";  <br> <br>Source                           Compatible Targets                       ENDIAN_FORMAT<br>-------------------------------- ---------------------------------------- ------------------------------------------<br>AIX-Based Systems (64-bit)       AIX-Based Systems (64-bit)               Big<br>AIX-Based Systems (64-bit)       Apple Mac OS                             Big<br>AIX-Based Systems (64-bit)       HP-UX (64-bit)                           Big<br>AIX-Based Systems (64-bit)       HP-UX IA (64-bit)                        Big<br>AIX-Based Systems (64-bit)       IBM Power Based Linux                    Big<br>AIX-Based Systems (64-bit)       IBM zSeries Based Linux                  Big<br>AIX-Based Systems (64-bit)       Solaris[tm] OE (32-bit)                  Big<br>AIX-Based Systems (64-bit)       Solaris[tm] OE (64-bit)                  Big<br> <br>8 rows selected.<br>
复制代码
小端格式 (Linux x86)
  1. SQL> set lines 200<br>SQL> set pages 200<br>SQL> COL "Source" FORM a32<br>SQL> COL "Compatible Targets" FORM a40<br>SQL> select d.platform_name "Source", t.platform_name "Compatible Targets", endian_format<br>from v$transportable_platform t, v$database d where t.endian_format = (select endian_format from v$transportable_platform t, v$database d where d.platform_name = t.platform_name) <br>order by "Compatible Targets";  <br> <br>Source Compatible Targets       ENDIAN_FORMAT<br>-------------------------------- ---------------------------------------- --------------<br>Linux x86 64-bit Apple Mac OS (x86-64)   Little<br>Linux x86 64-bit HP IA Open VMS       Little<br>Linux x86 64-bit HP Open VMS   Little<br>Linux x86 64-bit HP Tru64 UNIX   Little<br>Linux x86 64-bit Linux IA (32-bit)   Little<br>Linux x86 64-bit Linux IA (64-bit)   Little<br>Linux x86 64-bit Linux x86 64-bit   Little<br>Linux x86 64-bit Microsoft Windows IA (32-bit)   Little<br>Linux x86 64-bit Microsoft Windows IA (64-bit)   Little<br>Linux x86 64-bit Microsoft Windows x86 64-bit   Little<br>Linux x86 64-bit Solaris Operating System (x86)   Little<br>Linux x86 64-bit Solaris Operating System (x86-64)   Little<br> <br>12 rows selected.<br>
复制代码

下面是上文的中的SQL语句:
  1. SET lines 200<br>SET pages 200 <br>COL "Source" FOR a32 <br>COL "Compatible Targets" FOR a40<br>SELECT d.platform_name "Source",<br>       t.platform_name "Compatible Targets",<br>       endian_format<br>FROM v$transportable_platform t,<br>     v$database d<br>WHERE t.endian_format =<br>    (SELECT endian_format<br>     FROM v$transportable_platform t,<br>          v$database d<br>     WHERE d.platform_name = t.platform_name)<br>ORDER BY "Compatible Targets";<br>
复制代码
参考资料

[1] 原文地址: https://dbtut.com/index.php/2019/06/27/what-is-the-endian-format-in-oracle-databases/
扫描上面二维码关注我如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

圆咕噜咕噜

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表