![](/img/trans.png)
[英]What is the SQL Server equivalent for Oracle's systimestamp?
[英]What's the best equivalent for number(2, 4) from Oracle on the MS SQL server?
在 Oracle 上,可以創建比位數傳達的“更精確”的數字數據類型。 所以在number(2, 4)
的情況下,可以存儲 0.0023。 不可能像 0.12 甚至 0.001 那樣填充前兩位小數。 這將導致錯誤ORA-01438: value larger than specified precision allowed for this column
SQL 服務器不允許數據類型numeric(2, 4)
。 錯誤是: The scale (4) for column 'a' must be within the range 0 to 2.
顯然我可以使用numeric(4, 4)
創建表。
Oracle 上最精確的數字數據類型是number(38, 127)
。 十進制數字1到89不能填,只能填90到127。如果在SQL服務器上解決這樣的需求,你會怎么做?
您可以使用 CHECK 約束嗎? 例子:
ALTER TABLE tbl ADD col DECIMAL(4,4) CHECK (ABS(col) < 0.01);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.