Oracle缺少表列的Bit数据类型 [英] Oracle's lack of a Bit datatype for table columns

查看:299
本文介绍了Oracle缺少表列的Bit数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于不正确/不正确的情况,Oracle不支持bit数据类型或任何其他类型.是否会使用char(1)字段而不是使用特定字母表示是/真,而不考虑特定于文化的问题?

Oracle does not support a bit datatype or any other type for true/false scenarios. Does one use the char(1) field instead by using a specific letter to denote yes / true regardless of culture specific issues?

应该用Number(1,0)代替char-认为0/否/否,将其他解释为true/是吗?

Instead of char should it be Number(1,0) for this instead - 0 being considered false / no, anything else being interpreted as true / yes?

这可行吗?

为什么Oracle不支持简单的布尔类型?

Why does Oracle not support a simple boolean type?

推荐答案

相对于number(1),我更喜欢char(1),因为通过合理选择字符,很明显哪个字符具有哪个布尔含义.

I prefer char(1) over number(1), since with some reasonable choice of characters, it is obvious which character has which boolean meaning.

当然,您应该对所有不同的变体进行战斗,选择一个变体,并通过在列上放置检查约束来确保其被使用.

Of course you should fight all the different varations, choose one and ensure it's use by putting check constraints on the columns.

尽管在您的情况下可能已经很晚了,但是从其他工具生成模式通常至少要解决一致性问题.我个人更喜欢为此目的而休眠,但这是非常具体的情况.

Although it probably is to late in your case, generating the schema from another tool often takes care at least of the consistency issue. I personally prefer hibernate for this purpose, but that is very situation specific.

当然,这是一个明显的错误.更糟糕的是,PL/SQL有一个布尔值,但是您不能在SQL语句中使用它.

And of course that is a glaring obmission. To make it worse, PL/SQL has a boolean, but you can't use it in SQL statements.

这篇关于Oracle缺少表列的Bit数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆