Question

In: Computer Science

Use ap tables To test whether a table has been modified correctly as you do these...

Use ap tables

To test whether a table has been modified correctly as you do these exercises, you can write and run an appropriate SELECT statement. Or, when you’re using Oracle SQL Developer, you can click on a table name in the Connections window and then on the Data tab to display the data for all of the columns in the table. To refresh the data on this tab, click the Refresh button.

  1. Write an INSERT statement that adds this row to the Invoices table:

invoice_id                 The next id in sequence (find out what this should be)
vendor_id:                 32
invoice_number:        AX-014-027
invoice_date:             8/1/2008
invoice_total:            $434.58
payment_total:          $0.00
credit_total:               $0.00
terms_id:                   2
invoice_due_date:     8/31/2008
payment_date:           null

  1. Write an UPDATE statement that modifies the Vendors table. Change the default account number to 403 for each vendor that has a default account number of 400.
  2. Write an UPDATE statement that modifies the Invoices table. Change the terms_id to 2 for each invoice that’s for a vendor with a default_terms_id of 2.
  3. Write a DELETE statement that deletes the row that you added to the Invoices table in exercise 1.
  4. After you have verified that all of the modifications for the first four exercises have been successful, rollback the changes. Then, verify that they have been rolled back.

Solutions

Expert Solution

NOTE:

  • Execute 'commit;' command before all the queries so for exercise 5,when 'rollback'; command is executed for solution 5,it reverts all the changes till this point.

SOLUTION 1:

insert into invoice(invoice_id,vendor_id,invoice_number,invoice_date,invoice_total,payment_total,

credit_total,terms_id,invoice_due_date,payment_date) select max(invoice_id)+1,32,AX-014-027,'8/1/2008',$434.58,$0.00,$40.00,2,'8/31/2008',null from invoice;

Explanation :

  • 'select max(invoice_id)+1,32,AX-014-027,'8/1/2008',$434.58,$0.00,$40.00,2,'8/31/2008',null from invoice; ' creates a temperory table and these values are inserted into invoice

SOLUTION 2:

alter table vendors alter account_number set default 403;

Explanation :

  • changes the default value from 400 to 403

SOLUTION 3:

update invoice set term_id = 2 where vendor_id = 2;

SOLUTION 4:

delete from invoice order by invoice_id desc limit 1;

Explanation :

  • In exercise 1,the record was inserted in the last row,so using the invoice_id it is arranged in descending order and the first record is deleted

SOLUTION 5:

rollback;

For verifying purpose execute 'desc vendors' and the default value for account_number should be 400 and not 403.

 

Related Solutions

A multiple choice test has four possible responses. To test whether this question was answered correctly...
A multiple choice test has four possible responses. To test whether this question was answered correctly by more people than would be expected due to chance, a hypothesis test of 400 student answers is conducted. What is the null and alternative hypothesis (in words and symbols). If 218 of the 400 students got the correct response, what is the p-value? Explain your method and TI commands. What decision is made if a significance level of 0.01 is used? Based on...
When do you use a one-tailed test? When do you use a two-tailed test? How is...
When do you use a one-tailed test? When do you use a two-tailed test? How is SPSS used to perform the calculations needed for each?
use truth tables to determine whether or not the following arguments are valid: a) if jones...
use truth tables to determine whether or not the following arguments are valid: a) if jones is convicted then he will go to prison. Jones will be convicted only if Smith testifies against him. Therefore , Jones won't go to prison unless smith testifies against him. b) either the Democrats or the Republicans will have a majority in the Senate. but not both. Having a Democratic majority is a necessary condition for the bill to pass. Therefore, if the republicans...
Which punctuation marks do you think are most difficult to use correctly? Why? What might you...
Which punctuation marks do you think are most difficult to use correctly? Why? What might you do to help remember the rules for these punctuation marks or to make effective choices about these punctuation marks? United States answer only
You have been hired to test whether the demand for a product that your client produces...
You have been hired to test whether the demand for a product that your client produces varies between two demographic markets – the Urban and Rural markets. As such, in each market, you run a short survey that gauges customers demand for your product and assigns them to one of three categories – (i) High (ii) Medium or (iii) Low. You survey 70 people in the “Urban” market and find that their demand falls into the following “buckets” High                       32...
You have been hired to test whether the demand for a product that your client produces...
You have been hired to test whether the demand for a product that your client produces varies between two demographic markets – the Urban and Rural markets. As such, in each market, you run a short survey that gauges customers demand for your product and assigns them to one of three categories – (i) High (ii) Medium or (iii) Low. You survey 70 people in the “Urban” market and find that their demand falls into the following “buckets” High                       32...
You have been hired to test whether the demand for a product that your client produces...
You have been hired to test whether the demand for a product that your client produces varies between two demographic markets – the Urban and Rural markets. As such, in each market, you run a short survey that gauges customers demand for your product and assigns them to one of three categories – (i) High (ii) Medium or (iii) Low. You survey 80 people in the “Urban” market and find that their demand falls into the following “buckets” High 42...
You have been hired to test whether the demand for a product that your client produces...
You have been hired to test whether the demand for a product that your client produces varies between two demographic markets – the Urban and Rural markets. As such, in each market, you run a short survey that gauges customers demand for your product and assigns them to one of three categories – (i) High (ii) Medium or (iii) Low. You survey 80 people in the “Urban” market and find that their demand falls into the following “buckets” High 42...
You have been hired to test whether the demand for a product that your client produces...
You have been hired to test whether the demand for a product that your client produces varies between two demographic markets – the Urban and Rural markets. As such, in each market, you run a short survey that gauges customers demand for your product and assigns them to one of three categories – (i) High (ii) Medium or (iii) Low. You survey 80 people in the “Urban” market and find that their demand falls into the following “buckets” High 42...
For this assignment you have to create tables as reviewed in class Manufacturer table, Product table...
For this assignment you have to create tables as reviewed in class Manufacturer table, Product table and Stock table. The code is in Week 7 PPT lecture. You are to add update as needed to make the tables the same as below and match Product, Manufacturer and Stock as below. For this assignment you will be working with these same tables.   Please complete the following tasks and submit in word file or notepad. 1. First insert tuples into two of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT