sql - For NUMBER columns in Oracle, does specifying a length help performance? -


is there true difference in performance between number, number(3) , number(10)? doesn't rdbms use 32 bits store value regardless, , limit length of data when looked @ string?

a colleague debated was, example, more efficient use number(10) vs number/number(11), thinking n number of bytes rather length of data in characters. i'd agree limit column size if number of rows guaranteed not exceed 10^n or so, particular database limit number of rows literally "as many possible", e.g. 2^32 or ~4 billion, though we'd never reach amount. coming "lowest maximum" situation seems pointless , waste of time , thought using number without specifying length simpler , incur no penalties. correct?

technically, don't define length, precision , scale.

the same numeric value (eg 100, 4.3) takes same internal value irrespective of precision , scale defining column.

the maximum value column can hold determined both precision , scale. can store value 100 in column of number(3,0) not in column of number(3,1).

generally, if column shouldn't store decimal scale should zero. bear in mind if try store 10.12 in number(3,0) store value 10. doesn't error (because if did, you'd have hard time storing value of 1 third in anything). if want error want allow higher scale , use constraint stop ever being used.

i believe should try use 'sensible' precision too. if stored thousand values each second thousand years you'd still fit within 14 digits. if see column of number(14,0) know on screen or printout should allow 14 numeric characters displayed. if see number or number(38,0), haven't been given guidance , may guess @ 14 characters. , if start putting 16 character credit card numbers in there, i'll wrong. why prefer not guess.

also in pl/sql, have pls_integer datatype goes 2147483647. if see column of number(9,0) know can fit pls_integer. there's similar considerations java or .net etc. when want work out datatype, scale, precision use when pulling/pushing data database.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -