CSC 420
Laboratory:  Sequences and Indexes

Goals

  • To practice creating sequences and indexes for an Oracle database. 

Activities

  1. Create a new table called MY_CUSTOMER . The table should have the following structure.
  2. Column         Null?                Type                    Key    
    ID               NO                 NUMBER(7)               Primary
    NAME             NO                 VARCHAR2(50)
    PHONE                               VARCHAR2(25)
    COUNTRY                             VARCHAR2(30)
    CREDIT_RATING                       VARCHAR2(9)
  3. Confirm the structure of the MY_CUSTOMER table.
  4. Create a sequence generator named "S_MY_CUSTOMER_ID" for the MY_CUSTOEMR table column ID, starting with 300 and incrementing by 1 Do not cache sequence values.
  5. Display information about your sequence.
  6. Write a SQL statement to add more rows to the MY_CUSTOMER table. This statement should prompt your for the customer name, country, phone, and credit rating. The customer ID for a new customer should be supplied automatically by the statement. Save the SQL scrip under the name insert.customers.
  7. Execute insert.customers twice to add two rows of sample data to the MY_CUSTOMER table.
  8. Confirm your additions to the table by a query to the table.
  9. Display the sequence name and last_number of the S_MY_CUSTOMER_ID sequence.
  10. Create an index named "MY_CUSTOMER_NAME_I" on the NAME column of the MY_CUSTOMER table.
  11. Display information on your index.
  12. Drop the index created in the previous step.

Deliverables

    Turn in a hard copy of SQL commands and their corresponding outputs for each step in the lab first thing during the next class meeting.

Computer Science Department NSU.
Permission granted for non-commercial use only.