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

Write the commands in SQL Developer to perform the tasks described below. Then c

ID: 3919509 • Letter: W

Question

Write the commands in SQL Developer to perform the tasks described below. Then click on Write Submission and copy and paste the commands into the submission box. This assignment should be completed by July 30th

Create a sequence to generate new customer numbers for the customers table. Make sure that the values you use are consistent with the values that are already in the database.

Add a new customer to the customers table. Use the following information. Make sure the data you enter are formatted the same as the other data in the database.

The customer number should come from the sequence you created

The first name is Mary and the last name is Shoulders.

The address is 2230 Happy Valley Ln, Atlanta, Georgia, 30304.

She was referred by Jake Lucas.

Her e-mail address is M_Shoulders@yahoo.com.

Create an index for the books table based on the categories of the books. Name the index book_categories_index.

Create a synonym for the book_categories_index called category_idx.

Explanation / Answer

Step 1: Create a customers table with the following fields as shown below

            create table customers( customer_number NUMBER(5) PRIMARY KEY ,

   first_name varchar2(20),

                                                 last_name varchar2(20),

                                                 Address    varchar2(50),

                                               Reference varchar2(20),    

   E_mailID    varchar2(20) );

Step2 : Creating Sequence number named "customers_seq" starting with 1 and ends with 100

                create sequence customers_seq

                start with 1

increment by 1

maxvalue 100

                nocycle;

Step 3: Inserting a record with the given fields in to customers table

             insert into customers(customer_number,first_name,last_name,Address,Reference,E_mailID) values(customers_seq.nextvalue,'Mary','Shoulders',' 2230 Happy Valley

Ln, Atlanta, Georgia, 30304' , 'Jake Lucas' ,'M_Shoulders@yahoo.com');

row will be created here with customers sequence number 1

To create an index of books table based on category of the book

book table consists of 4 fields like book_id,book_name,book_category,book_price

create index book_categories_index on books(book_category);

Here book_categories_index has created

To Create a Synonym of name category_idx

create synonym category_idx for book_categories_index