由于十进制数据类型,导致表创建错误

时间:2018-07-27 13:24:41

标签: sql database teradata

我正在尝试创建此表,它显示错误“小数位数必须为0并且总位数”

Create Table DBL2.WorkOrderRouting
(
WorkOrderID int,
ProductID  Varchar(10),
OperationSequence int,
LocationID Varchar(10),
ScheduledStartDate Date,
ScheduledEndDate Date,
ActualStartDate Date,
ActualEndDate Date,
ActualResourceHrs Decimal (1,2),
PlannedCost Decimal (2,2),
ActualCost Decimal (2,5)
) Primary Index (WorkOrderID,ProductID,OperationSequence);

十进制似乎很好,我不明白。问题出在哪里!

1 个答案:

答案 0 :(得分:0)

您需要以另一种方式指定DECIMAL。第一个值必须高于第二个值:

Create Table DBL2.WorkOrderRouting
(
    WorkOrderID int,
    ProductID  Varchar(10),
    OperationSequence int,
    LocationID Varchar(10),
    ScheduledStartDate Date,
    ScheduledEndDate Date,
    ActualStartDate Date,
    ActualEndDate Date,
    ActualResourceHrs Decimal (3,2),
    PlannedCost Decimal (4,2),
    ActualCost Decimal (7,5)
) Primary Index (WorkOrderID,ProductID,OperationSequence);

您可以找到以下示例on the documentation

  

考虑数字256.78。其类型为DECIMAL(5,2)