COSC 641
FSU
Use tables testdata.employee, and testdata.department to answer the following questions:
1 - Check to see the list of existing sequences (what do you see and why?))
SELECT Sequence_Name
FROM SEQ; --USER_SEQUENCES
2 - What are the results of this query and why? (Explain each result and justify them)
SELECT testdata.P_Seq.CURRVAL, testdata.P_Seq.NEXTVAL,
FROM testdata.P_Seq.NEXTVAL, testdata.P_Seq.CURRVAL
DUAL;
3 - Insert one row of data into your table department. If you do not have department table, create one similar to testdata.deoartment. Use testdata.P_Seq.NEXTVAL for D_NUM field and “Promo” for the name of department)
4 -Check (display) the current value of sequence testdata.P_Seq.
5- Insert another row of data into your table department. Use testdata.P_Seq.NEXTVAL for D_NUM field and “HR” for the name of department)
6 -Display the number of rows, and the current value of the sequence from table department. Are the numbers are sequence? And why?
7 -Display the data in your department table.
8 -Create a “Temp10” table with the following fields:
Num
Year
Name
SerialNo
NUMBER
NUMBER
VARCHAR2 (25)
NUMBER
9 – Create a sequence called MySeq; that produces odd numbers.
10 – Display the sequence name, increment by value, cycle flag and last number stored in the database. Compare the last number with MySeq.CURRVAL.
11 – Create a script * to add a record into table Temp10 with Num = next sequence from
MySeq, Year = 2010, input Name from the keyboard, and SerialNo = SerialNo + 1. Do not use sequence for SerialNo.
12 – Add two records using the script created in 11.
13 – Display how many records exist in Temp10.
14 – Compare the count(*), last SerialNo, and CurrVal in MySeq.
15 – Create a view called Temp10View with, Year and Num in one field with a dash
(example 2008–5000), Name, and SerialNo for each row of table Temp10.
16 – We would like the next sequence number (MySeq) to be 351; modify your sequence.
(Do not drop and create a new sequence, continue producing add numbers)
17 – Insert a row in Temp10 table using script created in 11
18 – Display the data from table Temp10.
19- Display the data from the Temp10View.
* save your query and use it as script.