Question: Writing SQL Statements for the following tasks 1 . Create a table named yourfirstname _ store _ reps with the following columns: CREATE TABLE yourfirstname

Writing SQL Statements for the following tasks
1. Create a table named yourfirstname_store_reps with the following columns:
CREATE TABLE yourfirstname_store_reps (
rep_id NUMBER(5),
last VARCHAR2(15),
first VARCHAR2(10),
comm CHAR(1));
Modify the table so that rep_id is the PRIMARY KEY and the comm column has a default value of Y.(The comm column indicates whether the sales representative earns commission).
Write your SQL code here.
2. Modify the yourfirstname_store_reps table to ensure that NULL values cannot be entered in the first and last columns.
Write your SQL code here.
3. Modify the yourfirstname_store_reps table so that only a Y or N can be entered in the comm column.
Write your SQL code here.
4. Add a column named base_salary with a datatype of NUMBER(7,2) to the yourfirstname_store_reps table. Ensure that values entered are above zero.
Write your SQL code here.
5. Create a table named yourfirstname_book_stores with the following structure:
Column Names Data Types Constraints
store_id NUMBER(8) PRIMARY KEY
name VARCHAR2(30) UNIQUE, NOT NULL
content VARCHAR2(30)
rep_id VARCHAR2(5)
Write your SQL code here.
6. Ensure that the rep_id in the yourfirstname_book_stores table references a valid value in the yourfirstname_store_reps table. Make necessary modifications if the datatypes of rep_id are different in both tables.
Write your SQL code here.
7. Modify the constraint created in the previous question 6 so that deleting a row in the yourfirstname_store_reps table automatically deletes associated rows in yourfirstname_book_stores table .
Write your SQL code here.
8. Create a table named yourfirstname_rep_contracts with the following structure and constraints:
Columns: store_id (NUMBER(8)), name (VARCHAR2(5)), quarter (CHAR(3)), rep_id (NUMBER(5)).
Assign a composite PRIMARY KEY to rep_id,store_id, and quarter, and add FOREIGN KEY constraints to rep_id and store_id.
Write your SQL code here.
9. Display information about all existing constraints on the yourfirstname store_reps table.
Write your SQL code here.
10. Issue commands to disable and then enable the CHECK constraint on the base_salary column added in question 4.
Write your SQL code here.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!