Oracle
 sql >> Database >  >> RDS >> Oracle

Intero senza segno di Oracle SQL

Se vuoi rispettare le restrizioni mostrate qui , puoi utilizzare un vincolo di controllo:

SQL> create table foo (id number primary key, 
    constraint foo_uint_id check (id between 0 and 4294967295));

Table created.

SQL> insert into foo (id) values (-1);

insert into foo (id) values (-1)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.FOO_UINT) violated

SQL> insert into foo (id) values (0);

1 row created.

SQL> insert into foo (id) values (4294967295);

1 row created.

SQL> insert into foo (id) values (4294967296);

insert into foo (id) values (4294967296)
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.FOO_UINT_ID) violated

SQL> select * from foo;

        ID
----------
         0
4294967295