• <i id='7cUxM'><tr id='7cUxM'><dt id='7cUxM'><q id='7cUxM'><span id='7cUxM'><b id='7cUxM'><form id='7cUxM'><ins id='7cUxM'></ins><ul id='7cUxM'></ul><sub id='7cUxM'></sub></form><legend id='7cUxM'></legend><bdo id='7cUxM'><pre id='7cUxM'><center id='7cUxM'></center></pre></bdo></b><th id='7cUxM'></th></span></q></dt></tr></i><div id='7cUxM'><tfoot id='7cUxM'></tfoot><dl id='7cUxM'><fieldset id='7cUxM'></fieldset></dl></div>

    1. <tfoot id='7cUxM'></tfoot>
        <bdo id='7cUxM'></bdo><ul id='7cUxM'></ul>

      <small id='7cUxM'></small><noframes id='7cUxM'>

      <legend id='7cUxM'><style id='7cUxM'><dir id='7cUxM'><q id='7cUxM'></q></dir></style></legend>

      1. Oracle 中的布尔字段

        Boolean Field in Oracle(Oracle 中的布尔字段)

            <tbody id='aezKs'></tbody>

        1. <tfoot id='aezKs'></tfoot>

            <small id='aezKs'></small><noframes id='aezKs'>

            <i id='aezKs'><tr id='aezKs'><dt id='aezKs'><q id='aezKs'><span id='aezKs'><b id='aezKs'><form id='aezKs'><ins id='aezKs'></ins><ul id='aezKs'></ul><sub id='aezKs'></sub></form><legend id='aezKs'></legend><bdo id='aezKs'><pre id='aezKs'><center id='aezKs'></center></pre></bdo></b><th id='aezKs'></th></span></q></dt></tr></i><div id='aezKs'><tfoot id='aezKs'></tfoot><dl id='aezKs'><fieldset id='aezKs'></fieldset></dl></div>
            <legend id='aezKs'><style id='aezKs'><dir id='aezKs'><q id='aezKs'></q></dir></style></legend>
                  <bdo id='aezKs'></bdo><ul id='aezKs'></ul>

                • 本文介绍了Oracle 中的布尔字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  昨天我想向 Oracle 表中添加一个布尔字段.但是,Oracle 中实际上没有布尔数据类型.这里有人知道模拟布尔值的最佳方法吗?谷歌搜索这个主题发现了几种方法

                  1. 使用整数,并且不要为它分配 0 或 1 以外的任何值.

                  2. 使用带有Y"或N"作为仅有的两个值的字符字段.

                  3. 使用带有 CHECK 约束的枚举.

                  有经验的 Oracle 开发人员是否知道哪种方法是首选/规范的?

                  解决方案

                  我发现 这个链接很有用.

                  这是突出显示每种方法的一些优点/缺点的段落.

                  <块引用>

                  最常见的设计是模仿许多类似布尔的设计Oracle 的数据字典视图使用的标志,选择Y"为真'N' 表示假.但是,要与主机正确交互环境,例如 JDBC、OCCI 和其他编程环境,最好为 false 选择 0,为 true 选择 1,以便它可以工作正确使用 getBoolean 和 setBoolean 函数.

                  基本上他们提倡方法2,为了效率,使用

                  • 为 0/1(因为与 JDBC 的 getBoolean() 等的互操作性),带有检查约束
                  • 一个类型的CHAR(因为它使用的空间少于NUMBER).

                  他们的例子:

                  <块引用>

                  create table tbool (bool char check (bool in (0,1));插入 tbool 值(0);插入到 tbool 值(1);`

                  Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches

                  1. Use an integer and just don't bother assigning anything other than 0 or 1 to it.

                  2. Use a char field with 'Y' or 'N' as the only two values.

                  3. Use an enum with the CHECK constraint.

                  Do experienced Oracle developers know which approach is preferred/canonical?

                  解决方案

                  I found this link useful.

                  Here is the paragraph highlighting some of the pros/cons of each approach.

                  The most commonly seen design is to imitate the many Boolean-like flags that Oracle's data dictionary views use, selecting 'Y' for true and 'N' for false. However, to interact correctly with host environments, such as JDBC, OCCI, and other programming environments, it's better to select 0 for false and 1 for true so it can work correctly with the getBoolean and setBoolean functions.

                  Basically they advocate method number 2, for efficiency's sake, using

                  • values of 0/1 (because of interoperability with JDBC's getBoolean() etc.) with a check constraint
                  • a type of CHAR (because it uses less space than NUMBER).

                  Their example:

                  create table tbool (bool char check (bool in (0,1));
                  insert into tbool values(0);
                  insert into tbool values(1);`
                  

                  这篇关于Oracle 中的布尔字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  Creating a flattened table/view of a hierarchically-defined set of data(创建分层定义的数据集的扁平表/视图)
                  MySQL: how to do row-level security (like Oracle#39;s Virtual Private Database)?(MySQL:如何做到行级安全(如 Oracle 的 Virtual Private Database)?)
                  What is the best way to enforce a #39;subset#39; relationship with integrity constraints(强制执行具有完整性约束的“子集关系的最佳方法是什么)
                  Split String by delimiter position using oracle SQL(使用 oracle SQL 按分隔符位置拆分字符串)
                  How to unfold the results of an Oracle query based on the value of a column(如何根据列的值展开Oracle查询的结果)
                  <i id='UCZax'><tr id='UCZax'><dt id='UCZax'><q id='UCZax'><span id='UCZax'><b id='UCZax'><form id='UCZax'><ins id='UCZax'></ins><ul id='UCZax'></ul><sub id='UCZax'></sub></form><legend id='UCZax'></legend><bdo id='UCZax'><pre id='UCZax'><center id='UCZax'></center></pre></bdo></b><th id='UCZax'></th></span></q></dt></tr></i><div id='UCZax'><tfoot id='UCZax'></tfoot><dl id='UCZax'><fieldset id='UCZax'></fieldset></dl></div>

                      <legend id='UCZax'><style id='UCZax'><dir id='UCZax'><q id='UCZax'></q></dir></style></legend>
                        <tbody id='UCZax'></tbody>

                          <bdo id='UCZax'></bdo><ul id='UCZax'></ul>

                            <tfoot id='UCZax'></tfoot>

                            <small id='UCZax'></small><noframes id='UCZax'>