How can I CAST a numeric column to a NUMERIC with different precision and/or scale?

smontielsmontiel Vertica Customer
edited August 2020 in General Discussion

As part of integrating a new system we're focusing on dumping the information as PARQUET files but found out there is a limitation on precision and scale for NUMERIC fields. We thought about casting but can't figure out the syntax correctly and couldn't find anything online beyond altering the values in the table with an add/alter dance

Answers

  • Jim_KnicelyJim_Knicely - Select Field - Administrator

    Like this?

    dbadmin=> \d t
                                        List of Fields by Tables
     Schema | Table | Column |     Type      | Size | Default | Not Null | Primary Key | Foreign Key
    --------+-------+--------+---------------+------+---------+----------+-------------+-------------
     public | t     | c      | numeric(10,5) |    8 |         | f        | f           |
    (1 row)
    
    dbadmin=> SELECT c, c::NUMERIC(7, 2) FROM t;;
          c      |    c
    -------------+----------
     10021.23212 | 10021.23
       102.22823 |   102.23
         0.23100 |     0.23
    (3 rows)
    
    
  • smontielsmontiel Vertica Customer

    Thanks! I was using the CAST and didn't think about changing the format

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file