Basta specificare una lunghezza di 8 e una precisione di 0. Ti piace questa
SQL> create table t8 (col1 number(8,0))
2/
Table created.
SQL> insert into t8 values (12345678)
2/
1 row created.
SQL> insert into t8 values (123456789)
2/
insert into t8 values (123456789)
*
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column
SQL>
Per applicare una lunghezza esatta (tutti i numeri devono avere una lunghezza di otto cifre) è necessario utilizzare un vincolo CHECK:
SQL> alter table t8
2 add constraint t8_ck check (length(col1) = 8)
3/
Table altered.
SQL> insert into t8 values (1234567)
2/
insert into t8 values (1234567)
*
ERROR at line 1:
ORA-02290: check constraint (APC.T8_CK) violated
SQL>
vuoi 00000001 da memorizzare come 00000001 o 1, ad es questo numero di 8 cifre ha una lunghezza fissa a prescindere? – Andrew
Per completezza, è -12345678 un numero di otto cifre accettabile nel tuo caso? – pilcrow
sì, voglio che 000000001 venga memorizzato come 00000001, NON 1, perché voglio un numero di 8 cifre, esattamente 8! – MengT