Files
roacont/vanzari_detalii.sql

101 lines
3.3 KiB
SQL

-- Create table
create table VANZARI_DETALII
(
id_vanzare_det NUMBER(10) not null,
id_vanzare NUMBER(10) not null,
id_articol NUMBER(10),
id_pol NUMBER(10),
pret NUMBER(22,6) not null,
validat NUMBER(1) default 0 not null,
id_util_valid NUMBER(10),
dataora_valid DATE,
sters NUMBER(1) default 0 not null,
id_utils NUMBER(10),
dataoras DATE,
proc_tvav NUMBER(10,4),
cantitate NUMBER(20,4),
diferenta NUMBER(22,6) default 0 not null,
discount_unitar NUMBER(22,6),
id_gestiune NUMBER(20),
id_rata NUMBER(20),
cont VARCHAR2(4),
id_valuta NUMBER(10),
pret_cu_tva NUMBER(1),
explicatie VARCHAR2(500),
serie VARCHAR2(100),
pret_achizitie NUMBER(22,6),
id_vanzare_set NUMBER(10),
custodie NUMBER(1) default 0 not null,
id_jtva_coloana NUMBER(10),
descarcat NUMBER(1) default 0 not null,
dataora_descarcat DATE,
pretd NUMBER(22,6),
id_valutad NUMBER(10),
id_ctr NUMBER(10),
id_vanzare2 VARCHAR2(32),
id_jtva_coloana_ex NUMBER(10),
taxcode NUMBER(6),
lot VARCHAR2(20)
);
-- Add comments to the columns
comment on column VANZARI_DETALII.id_vanzare2
is 'VANZARI_DETALII.ID_VANZARE@MAGAZIN';
comment on column VANZARI_DETALII.id_jtva_coloana_ex
is 'JTVA_COLOANE_EXPLICATII.ID [OPTIONAL]';
comment on column VANZARI_DETALII.taxcode
is 'COD TAXA SAFT';
-- Create/Recreate primary, unique and foreign key constraints
alter table VANZARI_DETALII
add constraint PK_VANZARE_DET primary key (ID_VANZARE_DET)
using index
tablespace ROA
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table VANZARI_DETALII
add constraint FK_VANZARE_DET001 foreign key (ID_VANZARE)
references VANZARI (ID_VANZARE)
novalidate;
alter table VANZARI_DETALII
add constraint FK_VANZARE_DET002 foreign key (ID_ARTICOL)
references NOM_ARTICOLE (ID_ARTICOL)
novalidate;
alter table VANZARI_DETALII
add constraint FK_VANZARE_DET003 foreign key (ID_POL)
references CRM_POLITICI_PRETURI (ID_POL)
novalidate;
alter table VANZARI_DETALII
add constraint FK_VANZARE_DET004 foreign key (ID_UTIL_VALID)
references CONTAFIN_ORACLE.UTILIZATORI (ID_UTIL)
novalidate;
alter table VANZARI_DETALII
add constraint FK_VANZARE_DET005 foreign key (ID_UTILS)
references CONTAFIN_ORACLE.UTILIZATORI (ID_UTIL)
novalidate;
alter table VANZARI_DETALII
add constraint FK_VANZARI_DET006 foreign key (ID_RATA)
references CTR_SCADENTAR (ID_RATA);
alter table VANZARI_DETALII
add constraint FK_VANZARI_DET007 foreign key (ID_VALUTA)
references NOM_VALUTE (ID_VALUTA);
alter table VANZARI_DETALII
add constraint FK_VANZARI_DET008 foreign key (ID_VANZARE_SET)
references VANZARI_SETURI (ID_VANZARE_SET);
alter table VANZARI_DETALII
add constraint FK_VANZARI_DET009 foreign key (ID_JTVA_COLOANA)
references JTVA_COLOANE (ID_JTVA_COLOANA)
disable
novalidate;
alter table VANZARI_DETALII
add constraint FK_VANZARI_DET010 foreign key (ID_CTR)
references CONTRACTE (ID_CTR);