Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the table structure shown in the figure INVOICES - Columns Data Constra

ID: 3707760 • Letter: C

Question

Consider the table structure shown in the figure INVOICES - Columns Data Constraints Grants Statistics ITriggers |Flashback IDependencies IDetails Partitions Indexes SQL ?K ? Actions... COMMENTS 1 (null) 2 (null) 3 (null) 4 (null) 5 (null) 6 (null) 7 (null) 8 (null) 9 (null) 10 (null) COLUMN NAME 1 INVOICEID 2 VENDOR ID 3 INVOICE_NUMBER VARCHAR2(50 BYTE) No 4 INVOICE DATE DATA TYPE NUMBER NUMBER NULLABLE DATA DEFAULT St COLUMN ID No No No No Yes Yes No No (null) (null) (null) (null) (null) 0 0 (null) (null) (nul) DATE 5 INVOICE_TOTAL NUMBER(9,2) 6 PAYMENT_TOTAL NUMBER(9,2) NUMBER(9,2) 7 CREDIT TOTAL 8 TERMS_ID 9 INVOICE DUE DATE DATE 10 PAYMENT DATE DATE NUMBER es Write an Oracle-compatible SQL script that declares a variable and then sets it equal to the sum of all the rows in the invoices table that have a balance due that is greater than or equal to a certain amount (you choose the amount). Then the script should display a message that states whether or not the sum of invoice totals exceeds $50,000

Explanation / Answer

SOLUTION :

ALTER TABLE INVOICES ADD CONSTRAINT uq_invoice UNIQUE(VENDOR_ID, INVOICE_NUMBER);

for the Create a new constraint with both vendor_id and invoice_number