DECIMAL 和 NUMERIC 在 BigQuery 中是等价的,两者用于定义精度和标度的数据类型。以下是一个使用 DECIMAL 和 NUMERIC 的示例:
-- create a table with DECIMAL type CREATE TABLE my_table ( my_decimal DECIMAL(10,3) );
-- insert a value into my_decimal column INSERT INTO my_table (my_decimal) VALUES (1234.567);
-- create a table with NUMERIC type CREATE TABLE my_table_2 ( my_numeric NUMERIC(10,3) );
-- insert a value into my_numeric column INSERT INTO my_table_2 (my_numeric) VALUES (1234.567);
-- query the table with DECIMAL type SELECT * FROM my_table;
-- output +-------------+ | my_decimal | +-------------+ | 1234.567000 | +-------------+
-- query the table with NUMERIC type SELECT * FROM my_table_2;
-- output +-------------+ | my_numeric | +-------------+ | 1234.567000 | +-------------+