postgresql - Where are NUMERIC precision and scale for a field found in the pg_catalog tables? -


In PostgreSQL, the column data is stored in pg_attribute for table structure, in which some fields are in pg_class and a couple Pg_attrdef.

But I do not see the exact or scale for a NUMERIC field type stored anywhere

It can be found in INFORMATION_SCHEMA tables, but I am trying to avoid them , Because they do not use odds to easily join pg_catalog tables.

So the question is: Where is the column stored in PostgreSQL system tables accurate and scale?

This is stored in pg_attribute, in column atttypmod is available to view all information information_schema.columns This view Uses some questions to calculate the values: These are the basics:

  select atttypid when 21 / * int2 * / THEN 16 WHEN 23 / * int4 * / THEN 32 WHEN 20 / * Int8 * / THEN 64 WHEN 1700 / * Numeric * / Then in case atttypmod = -1 THEN tap ELSE ((atttypmod - 4)> 16) & amp; Numerical precision as 65535 - 700 / * float 4 * / THEN 24 / * FLT_MANT_DIG * / when 701 / * float 8 * / THEN 53 / * DBL_MANT_DIG * / ELSE tap end, exact end in case (21, 23, 20 ) Then 0 when atttypid IN (1700) then case atttypmod = -1 then tap ELSE (atttypmod - 4) & amp; 65535 - Number END calculation of numeric_scale as ELSE tap termination, * pg_attribute;  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -