Create a paid invoices table that has the same structure as the invoices table, but it does not need any foreign key constraints (or other constraints, for that matter) since data will be transferred into the paid table in order to archive them out of the normal invoices table.
Invoices table:
create table invoices
(
invoice_id number(10),
vendor_id number(10) not null,
invoice_number varchar2(50) not null,
invoice_date date not null,
invoice_total number(9,2) not null,
payment_total number(9,2) default 0,
credit_total number(9,2) default 0,
terms_id number(10) not null,
invoice_due_date date not null,
payment_date date,
constraint invoices_pk
primary key (invoice_id),
constraint invoices_fk_vendors
foreign key (vendor_id)
references vendors (vendor_id),
constraint invoices_fk_terms
foreign key (terms_id)
references terms (terms_id)
);
create table paidinvoice(
invoice_id number(10),
vendor_id number(10),
invoice_number varchar2(50),
invoice_date date,
invoice_total number(9,2),
payment_total number(9,2),
credit_total number(9,2),
terms_id number(10),
invoice_due_date date,
payment_date date
);
Note:
Since in the question it is given the structure of the invoice
table is maintained i used all the columns of the invoice table in
the paid invoice table ,but in this table we are not using any
constraints.
Get Answers For Free
Most questions answered within 1 hours.