前言:本文是对这篇博客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查看数据库中的当前字节序格式。
SQL> select name,platform_id,platform_name from v$database;
NAME PLATFORM_ID PLATFORM_NAME
--------- ----------- ----------------------------------------------------------
ORCL 13 Linux x86 64-bit
以下查询显示了可以移动现有数据库的其他环境。
大端格式 (IBM AIX)
SQL> set lines 200
SQL> set pages 200
SQL> COL "Source" FORM a32
SQL> COL "Compatible Targets" FORM a40
SQL> select d.platform_name "Source", t.platform_name "Compatible Targets", endian_format
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)
order by "Compatible Targets";
Source Compatible Targets ENDIAN_FORMAT
-------------------------------- ---------------------------------------- ------------------------------------------
AIX-Based Systems (64-bit) AIX-Based Systems (64-bit) Big
AIX-Based Systems (64-bit) Apple Mac OS Big
AIX-Based Systems (64-bit) HP-UX (64-bit) Big
AIX-Based Systems (64-bit) HP-UX IA (64-bit) Big
AIX-Based Systems (64-bit) IBM Power Based Linux Big
AIX-Based Systems (64-bit) IBM zSeries Based Linux Big
AIX-Based Systems (64-bit) Solaris[tm] OE (32-bit) Big
AIX-Based Systems (64-bit) Solaris[tm] OE (64-bit) Big
8 rows selected.
小端格式 (Linux x86)
SQL> set lines 200
SQL> set pages 200
SQL> COL "Source" FORM a32
SQL> COL "Compatible Targets" FORM a40
SQL> select d.platform_name "Source", t.platform_name "Compatible Targets", endian_format
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)
order by "Compatible Targets";
Source Compatible Targets ENDIAN_FORMAT
-------------------------------- ---------------------------------------- --------------
Linux x86 64-bit Apple Mac OS (x86-64) Little
Linux x86 64-bit HP IA Open VMS Little
Linux x86 64-bit HP Open VMS Little
Linux x86 64-bit HP Tru64 UNIX Little
Linux x86 64-bit Linux IA (32-bit) Little
Linux x86 64-bit Linux IA (64-bit) Little
Linux x86 64-bit Linux x86 64-bit Little
Linux x86 64-bit Microsoft Windows IA (32-bit) Little
Linux x86 64-bit Microsoft Windows IA (64-bit) Little
Linux x86 64-bit Microsoft Windows x86 64-bit Little
Linux x86 64-bit Solaris Operating System (x86) Little
Linux x86 64-bit Solaris Operating System (x86-64) Little
12 rows selected.
下面是上文的中的SQL语句:
SET lines 200
SET pages 200
COL "Source" FOR a32
COL "Compatible Targets" FOR a40
SELECT d.platform_name "Source",
t.platform_name "Compatible Targets",
endian_format
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)
ORDER BY "Compatible Targets";
参考资料
原文地址: https://dbtut.com/index.php/2019/06/27/what-is-the-endian-format-in-oracle-databases/
文章来源: 博客园
- 还没有人评论,欢迎说说您的想法!