建表的时候字段类型设置为 numeric(9,2),查询表结构的时候从 pg_attribute读出的atttypmod值为589830, 请问postgresql是怎么从这个589830计算出精度为 9,2的?
解决方案 »
- mysql用控制台突然无法登陆了,报1045错误
- mysql数据库中记录条数超过了bigint的最大长度,自增编号会怎么样
- 一条查询语句,3.0版本可以运行,5.0不行,
- [InnoDB建立外键问题]
- SQuirreL SQL Client操作Mysql是的中文乱码问题
- 求助:Table '*******' doesn't exist
- 请问mysql的auto_increment字段是否一定要定义为主关键字?
- mysql的外键和事物处理
- mysql查询问题
- 在线等,SQL Server 或 (ASP.NET) 怎么向 低版本的 MySQL写数据,MySQL的版本号 3.23.49
- 请问这样的表如何处理...mysql
- MYSQL超难多表查询
f1 numeric(5,2),
f2 numeric(5,3),
f3 numeric(5,4),
f4 numeric(5,2),
f5 numeric(6,2),
f6 numeric(7,2),
f7 numeric(8,2),
f8 numeric(9,2)
);然后看一下,这个表中这些字段的atttypmod 是多少?贴出来大家或许能找到规律。
nueric(5,3) => 327687
nueric(5,4) => 327688
nueric(5,5) => 327689
nueric(2,2) => 393222
nueric(7,2) => 458758
nueric(8,2) => 524294
nueric(9,2) => 589830
再加一点信息 在数据库中 numeric对应的typeid是 1700
第一个字节为 numeric (n,m) 的N, 最后一个字节为 m+4[code=BatchFile]nueric(5,2) => 327686 0101 0000 0000 0000 0110
nueric(5,3) => 327687 0101 0000 0000 0000 0111
nueric(5,4) => 327688 0101 0000 0000 0000 1000
nueric(5,5) => 327689 0101 0000 0000 0000 1001
nueric(2,2) => 393222 0110 0000 0000 0000 0110
nueric(7,2) => 458758 0111 0000 0000 0000 0110
nueric(8,2) => 524294 1000 0000 0000 0000 0110
nueric(9,2) => 589830 1001 0000 0000 0000 0110[/code]
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
*
* column_size =((atttypmod - VARHDRSZ) >> 16) & 0xffff
* decimal_digits = (atttypmod - VARHDRSZ) & 0xffff
*