Question: write the SQL statements to do the following: a. Modify the CUSTOMER table so the customer number field is set to auto increment and the

write the SQL statements to do the following:

a. Modify the CUSTOMER table so the customer number field is set to auto increment and the auto increment value is set to 2000. (Note: The INVOICE table will need to be modified first to remove the foreign key constraint on the customer number. After the auto increment value property has been added to the customer number field, add the foreign key constraint back to the INVOICE table).

b. Modify the INVOICE table so the invoice number field is set to auto increment and the auto increment value is set to 9000.

Save all the SQL statements as a script. Copy and paste an image of the script after a successful run showing the SQL statements and all the log results below (no results grid will be displayed).

The MySQL command to remove a foreign key constraint has the following format:

ALTER TABLE tbl_name DROP FOREIGN KEY constraint_name;

(The constraint_name can be found in the table properties under the foreign keys tab)

The MySQL command to modify a column to be auto increment has the following format:

ALTER TABLE tbl_name MODIFY COLUMN col_name col_type AUTO_INCREMENT;

The MySQL command to set an auto increment value has the following format:

ALTER TABLE tbl_name AUTO_INCREMENT = value;

The MySQL command to add a foreign key constraint has the following format:

ALTER TABLE tbl_name ADD FOREIGN KEY (col_name) REFERENCES tbl_name(col_name);

ch08_simpleco database schema created in problem 1:

1. DROP SCHEMA IF EXISTS ch08_simpleco; 2. CREATE DATABASE ch08_simpleco; 3. USE

1. DROP SCHEMA IF EXISTS ch08_simpleco; 2. CREATE DATABASE ch08_simpleco; 3. USE ch08_simpleco; 4 5 6 7 8 9 10 11 12 13 14 125 9 16 17 18 CREATE TABLE customer ( ); CUST_NUM INT (11) PRIMARY KEY, CUST_LNAME VARCHAR(30), CUST_FNAME VARCHAR(30), CUST_BALANCE DECIMAL (8, 2) CREATE TABLE invoice ( ); INV_NUM INT (11) PRIMARY KEY, CUST_NUM INT (11), INV_DATE DATE, INV_AMOUNT DECIMAL (10, 2), FOREIGN KEY (CUST_NUM) REFERENCES customer (CUST_NUM)

Step by Step Solution

3.38 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To accomplish the tasks outlined you will need to execute a series of SQL statements making sure you ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!