Search code examples
sqloracle-databaseoracle11goracle10gcreate-table

Oracle Database unsigned integer


I want too know ,If Oracle Database support unsigned int(number) how I can use it or if not what is alternative of this? I don't need way to put condition for SQL syntax because all my data is positive and it's important unsigned int for performance and storage.


Solution

  • I don't think that Oracle provides a specific datatype for unsigned integers. It provides a single datatype to store fixed numeric values, called NUMBER, whose precision and scale can be adjusted as needed.

    In Oracle, the so-called INT datatype is a syntactical sugar provided for ANSI compatibility, which internaly maps to NUMBER.

    I would recommend a number with a 0 scale (that's an integer), and a check constraint to ensure that it is positive:

    create table mytable (
        id number(20, 0) check (id >= 0)
    );