Oracle
 sql >> Base de données >  >> RDS >> Oracle

Entier non signé Oracle SQL

Si vous souhaitez faire correspondre les restrictions affichées ici , vous pouvez utiliser une contrainte de vérification :

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