Sunteți pe pagina 1din 3

Oracle Practice

Create Tables
1. Student Information Table
Column Name Student_ID Last_Name First_name DOB Address City Telephone Email Data Type Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Length 20 25 20 20 300 20 8 25 Constraint Type

2. Department Information Table


Column Name Dept_Id Dept_Name Data Type Varchar2 Varchar2 Length 20 25 Constraint Type Primary Key

3. Instructors Information Table


Column Name Inst_ID Dept_Name Last_name First_name Telephone Email Data Type Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Length 20 20 25 20 20 200 Constraint Type

4. Course Information
Column Name Course_ID Dept_ID Title Description Fees Duration Data Type Varchar2 Varchar2 Char Varchar2 Varchar2 Varchar2 Length 5 20 25 20 20 20 Constraint Type Primary Key

5. Class Table
Column Name Class_ID Class_Room Course_ID Dept_ID Ins_ID Start_Time Data Type Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Date Length 20 20 5 20 20 Constraint Type

Altering the Table


1. Student Table a) Add a new column sex, which is of char datatype. b) Alter the column size of first_name and last_name to 10. c) Alter the datatype of DOB to date. d) Add a primary key constraint for the student_id. e) Alter datatype of the column telephone to number. 2. Instructor Table a) Add new column sex, which is of char datatype. b) Add a new column position which is of datatype varchar2 and size 25. c) Alter the new column position with a check constraint which checks for ASSISTANT PROFESSOR,ASSOCIATE PROFESSOR, PROFESSOR. 3. Class Table a) Add a foreign key for the column dept_id which refers Department(Dept_Id). b) Add a foreign key to course_id. c) Add composite primary key to columns (course_id,dept_id); Insert Records (10 Valid Data) 1. Student Table 2. Department Table 3. Instructor Table 4. Course Table 5. Class Table

Display the rows from the tables with the following criteria.
1. Display all information from the student table whose last_name is null. 2. Display the student Id and the First Name from the student table who doesnt have a telephone and email. 3. Display Students First Name whose city is Kathmandu. 4. Display Students Last Name whose state starts with the letter S 5. Display Students ID, Last Name whose state ends with the letter A. 6. Display Students First Name and Last Name Concatenated. 7. Display Students First Name and Last name Concatenated. 8. Display all information from the Student Table where the Students First name is only of five characters. 9. Display Students First Name, Id and their age. 10. Display Students Id whose age is greater than 20. 11. Display Student First Name, DOB whose birthday falls today. 12. Display the Students First Name, Address whose birthday fall in the month of January. 13. Display the eldest male students First Name from the Student table. 14. Display all information of the youngest female student from the Student Table. 15. Display the student id whose age is greater than 23 as on current date. 16. Display the students id whose age is greater than 25 as on the current date. 17. Display the Instructors First Name, last name concatenated together and the first character in capitals. 18. Display the Student First Name all in capitals. 19. Display the last day of the current month. 20. Display the first day of a given year. 21. Display the last day of a given year. 22. Display the number of months of the students since their birth. 23. Display the next date of that immediately follows the systdate. 24. Display the greater of two given dates. 25. Display the students date of birth rounded to the nearest month. 26. Display the average age of the students. 27. Display the number of unique cities from the student table. 28. Display the student id from the student table whose last name is unique. 29. Display the Students First Name, DOB in the format of DD-MONTH-YYYY. 30. Display the Student Id, First Name from the student table whose Telephone contains two zeros.

S-ar putea să vă placă și