查询 DECIMAL 列的精度和小数位数
Query the Precision and Scale of a DECIMAL column
我想找到数据类型为 DECIMAL 的列的 numeric_precision 和 numeric_scale。
我试过了
SELECT DATA_TYPE, COLUMN_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'X'
但这只给我 "decimal"
您可以查询系统视图information_schema.columns
。我认为您正在寻找列 numeric_precision
和 numeric_scale
select numeric_precision, numeric_scale
from information_schema.columns
where table_schema = ? and table_name = ? and column_name = ?
create table t (col decimal(10, 2));
select numeric_precision, numeric_scale
from information_schema.columns
where table_schema = 'dbo' and table_name = 't' and column_name = 'col'
numeric_precision | numeric_scale
:---------------- | ------------:
10 | 2
我想找到数据类型为 DECIMAL 的列的 numeric_precision 和 numeric_scale。
我试过了
SELECT DATA_TYPE, COLUMN_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'X'
但这只给我 "decimal"
您可以查询系统视图information_schema.columns
。我认为您正在寻找列 numeric_precision
和 numeric_scale
select numeric_precision, numeric_scale
from information_schema.columns
where table_schema = ? and table_name = ? and column_name = ?
create table t (col decimal(10, 2));
select numeric_precision, numeric_scale
from information_schema.columns
where table_schema = 'dbo' and table_name = 't' and column_name = 'col'
numeric_precision | numeric_scale :---------------- | ------------: 10 | 2