Table is not generated in Oracle database

Asked

Viewed 403 times

2

That normal wheel:

create table M_VENDEDORES (
ID_VENDEDOR number (10,0) not null,
NOME varchar2 (100) not null,
CPF number (11,0) not null,
ENDERECO varchar2 (100) not null,
NUMERO varchar2 (10) not null,
CEP number (11,0) not null,
constraint PK_VENDEDOR PRIMARY KEY (ID_VENDEDOR),
constraint UK_CPF unique (CPF)
);

That normal wheel:

create table M_VENDAS (
ID_VENDEDOR number (10,0) not null,
MES varchar2 (100) not null,
VENDAS number (10) not null,
constraint FK_ID_VENDEDORES foreign key (ID_VENDEDOR)
references M_VENDEDORES (ID_VENDEDOR)
);

That normal wheel:

create table M_FORNECEDORES (
ID_FORNECEDOR number (10,0) not null,
NOME varchar2 (100) not null,
CNPJ number (14) not null,
constraint PK_FORNECEDOR PRIMARY KEY (ID_FORNECEDOR)
);

This does not wheel normal:

create table M_ESTOQUE (
ID_FORNECEDOR number (10,0) not null,
ID_ITEM number (10,0) not null,
NOME varchar2 (100) not null,
MODELO varchar2 (100) not null,
TAMANHO varchar2 (10) not null,
MARCA varchar2 (100) not null,
ESTOQUE number (100) not null,
constraint PK_ITEM PRIMARY KEY (ID_ITEM),
constraint FK_ID_FORNECEDOR foreign key (ID_FORNECEDOR)
references M_FORNECEDORES (ID_FORNECEDOR)
);

Returns this error:

Log do erro: create table M_ESTOQUE (
ESTOQUE number (100,0)
)
Relatório de erros -
ORA-01727: o especificador de precisão numérica está fora da faixa válida (1 a 38)
01727. 00000 -  "numeric precision specifier is out of range (1 to 38)"
*Cause:    
*Action:

1 answer

1


Your problem is here:

ESTOQUE number (100) not null,

A number with 100 digits is beyond what Oracle can process. Its limit is 38 digits.

There are two possible exits:

  • Decrease the field size.

  • Change him to varchar2.

If this field will only store a code of something (even if this code is a sequence of digits), I recommend using varchar2 (maybe it is the cases of the camps CEP, CPF and CNPJ).

If this field represents the quantity in stock of a product, surely working with 100 digits is an exaggeration and a much smaller number of digits (such as 10) would be more than enough.

  • Good evening Victor! Thank you very much I understood what I was doing wrong. .

Browser other questions tagged

You are not signed in. Login or sign up in order to post.