Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果事先知道数据长度限制,那么在声明表时限制数据类型是否有任何好处?
create table "user"."table" ( ... "is_there_any_profit" number (1, 0) )
对比
create table "user"."table" ( ... "is_there_any_profit" number )
从技术上讲不是,所有数字都以相同的方式存储(尾数+指数)。利润在于业务逻辑规则的实现。如果您希望将整数存储到数据库中,最好通过设置正确的数据类型(例如 NUMBER(10,0))来强制执行此操作。您声明,其他值无效。