Oracle database experiment report five indexes, views and sequences

Experiment 5 Indexes, Views and Sequences

-by QQC from BTBU

[Experimental purpose]
Master the basic usage methods of indexes, views and sequences in Oracle.
[Experimental content]
1. After connecting to the database with the hr user, add an index to the DEPARTMENT_ID column of the EMPLOYEES table.
Add an index to the DEPARTMENT_ID column of the EMPLOYEES table

After connecting, query the index to know that the department_id of the employees table has an index emp_department_id, so you need to delete the index before you can add the index operation as follows

Delete index
Create index

2. Modify the previous index to be an inverse key index
Modified to inverse key index

3. Delete the index.

Delete the index in step 1

4. Create the view VEMPLOYEE, including all the data in the EMPLOYEES table, as well as the JOB_TITLE and DEPARTMENT_NAME of each employee.

You can first query the content you need through select, and then add create view to the first line of ed

Create view

5. Check the view created in the previous step. After the data is correct, delete the view.

In the viewing process, the data can be displayed neatly through col for and heading

Insert picture description here
Insert picture description here

delete

Insert picture description here

6. Create the sequence COUNTRY_SEQ, starting from 100 and incrementing by 1 each time. Insert the RUSSIA record in the COUNTRY table and use this sequence at the same time.

First create the sequence

Create sequence

After querying the country table does not exist, so we need to create a country table first, and then insert data

Insert picture description here
Use sequence

Here I have added one/demonstrated the effect of seq.nextval, but I don’t actually need to add it

7. Modify the sequence created in the previous step so that the increment unit is 10 each time, and insert a record again.
Modify sequence

8. After checking that the sequence is used correctly, delete the sequence.

The above select check is correct and can be deleted

Delete sequence

Guess you like

Origin blog.csdn.net/AQ_No_Happy/article/details/110501508