0% found this document useful (0 votes)
1K views5 pages

SQL Test Paper

This document contains an Oracle SQL test with three sections - multiple choice questions, short answer questions, and true/false statements. It tests knowledge of SQL commands like CREATE TABLE, SELECT, INSERT, DELETE, ALTER TABLE, sequences, views, joins, constraints and more. The test is designed to evaluate understanding of SQL fundamentals like data definition, manipulation, integrity rules and querying.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
1K views5 pages

SQL Test Paper

This document contains an Oracle SQL test with three sections - multiple choice questions, short answer questions, and true/false statements. It tests knowledge of SQL commands like CREATE TABLE, SELECT, INSERT, DELETE, ALTER TABLE, sequences, views, joins, constraints and more. The test is designed to evaluate understanding of SQL fundamentals like data definition, manipulation, integrity rules and querying.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

ORACLE SQL TEST - 1 Max Marks : 50 SECTION I Please answer the following questions in a separate white paper provided

d to you. Choose the Correct Choices from multiple choices provided for each question , Note that More Than one choice may be correct , List all of them. Each Question Carries 2 marks:
1. Examine the following command: CREATE TABLE pay (employee_id Number(9) CONSTRAINT pay_pk PRIMARY KEY, 2000_pay NUMBER(8,2) manager_name VARCHAR2(25) CONSTRAINT mgr_name_nn. NOT NULL, pay_96 NUMBER(8,2)); Which two lines of this command will return an error? a. First b. Second c. Third d. Fourth e. Fifth f. Sixth g. Seventh 2. The worker table contains the following columns: First_name Last_name VARCHAR2(25) VARCHAR2(25)

Time : 2 hours

Evaluate these two SQL statements: SELECT CONCAT (first_name,last_name), LENGTH(CONCAT(first_name,last_name)) FROM worker WHERE UPPER(last_name)like %J OR UPPER (last_name)like %K OR UPPER (last_name)like %L; SELECT INITCAP(first_name)|| INITCAP(last_name), LENGTH(last_name)+LENGTH(first_name) FROM worker WHERE INTICAP(substr(last_name,1,1)) IN ( J, K, L);

How will results differ between the two SQL statements? a. b. c. d. Different data will be retrieved from the database. The same data will be retrieved, but it will be displayed differently. The first statement will be executed; the second will not. The second statement will be executed; the first will not.

3. Which of the following statements regarding SQL is true?


a. b. c. d. 4. Null values are displayed last in ascending sequences. Data values are displayed in descending order by default. You cannot specify a column alias in an ORDER BY clause. Query results cannot be sorted by a column that is not included in the SELECT list. You are a user of the PROD database, which has over 1200 tables. What data dictionary view must you query to determine the number of tables you can access? ALL_OBJECTS DBA_TABLES DBA_SEGMENTS USER_OBJECTS

a. b. c. d.

5 . Examine the following: Name PUPIL_ID NAME ADDRESS GRADUATION Null? NOT NULL NOT NULL Type NUMBER(3) VARCHAR2(25) VARCHAR2(50) DATE

Which of these statements inserts a new row into the PUPIL table? a. INSERT INTO pupil VALUES(121, 'Benson'); b. INSERT INTO pupil VALUES(121, '50 NE Oak St.', '20-MAR-01', 'Benson'); c. INSERT INTO PUPIL VALUES(121, 'Benson', '50 NE Oak St.', '20-MAR-01'); d. INSERT INTO pupil.(pupil_id,address,name,graduation) VALUES(121, '50 NE Oak St.', 'Benson', '20-MAR-01'); 6. Within SQL Plus, you issue the following: Delete from DEPT where deptno=10; You receive an integrity constraint error indicating the child record was found. What should be done to make the statement execute?

a. Delete the child record first. b. Add a fourth keyword to the command. c. Add the cascade constraints option to the command. d. The statement cannot be executed. 7. The view WORKER_VIEW is created based on the WORKER table as follows: CREATE OF REPLACE VIEW worker_view AS SELECT deptno,Sum(sal) TOT_SAL FROM worker GROUP BY deptno; What happens when the following command is issued? UPDATE worker_view SET TOT_SAL=25000 WHERE deptno=8; a. b. c. d. The base table cannot be updated through this view. The TOT_SAL column in the WORKER table is updated to 25,000 for department 8. The TOT_SAL column in the WORKER view is updated to 25,000 for department 8. The SAL column in the WORKER table is updated to 25,000 for employees in department 8.

8. You issue the following command: CREATE public synonym WORKER for ed.worker; What is the result of the command? a. The object can be accessed by all users. b. All users are given object privileges to the table. c. The need to qualify the object name with its schema is eliminated only for the commanding issuer. The need to qualify the object name with its schema is eliminated for all users. 9. Mrs. Jensen is president of her company. Four managers report to her, and all other employees report to the four managers. Examine the following: SELECT worker.wname FROM work worker WHERE worker.workno not in (SELECT manager.mgr FROM work manager) ; The above statement returns no rows. Why? a. b. c. d. All employees have a manager. None of the employees have a manager. A null value is returned from the subquery. An operator is not allowed in sub queries.

10. You must permanently remove all data from the INVOICE table, but will need the table structure in the future. What single command should be issued? a. b. c. d. DROP TABLE invoice TRUNCATE TABLE invoice DELETE FROM invoice TRUNCATE TABLE invoice KEEP STRUCTURE.

SECTION II Please answer the following questions on separate white paper provided to you. Each question carries 2 marks. 1. Write a query to display the employees who are hired in the first quarter of the year from emp table ? 2. Write a SQL Statement to delete all employees who are earning the salary less than the salary of CLERKS ? 3. Create a View which shows employee details along with their salary grade and department name in which they are working ? 4. Alter the emp table to add the following columns ( Using one alter statement ). Marital_Status char(1) default value = 'S' bonus_allowed char(1) default value = 'N' 5. Show the top 3 earning salesmen from the emp table ? 6. Using Set operators find out the difference between emp_trans and emp table ? 7. Write a query to display deptno, dname, loc, and Average Salary of those departments who has CLERKS and MANAGERS ? 8. Create a sequence such that it produces the following sequence of numbers ? 400 300 200 100 0 -100 -200 ...... 9. Merge the emp_trans table which has undergone changes with emp table ? 10. Delete the department where least number of clerks work ?

SECTION III Please Answer the following questions in a separate white paper provided to you. Mark 'T' if the Statement is TRUE , 'F' if the statement is FALSE. Each Question carries 1 mark. 1. GROUP BY Clause can be written after the HAVING CLAUSE in a SELECT Statement. 2. If a table is dropped , all disabled constraints are also dropped. 3. We can use column alias to qualify a column in USING Clause of JOIN in 9i. 4. We can create view based on another view. 5. The constraint type column in USER_CONSTRAINTS Data Dictionary view has letter 'R' for Foreign Key Constraint. 6. We can add a column in the middle of two columns in a table. 7. The maximum number of columns in an Oracle 10g Table is 256. 8. If we concatenate a null value with another null value , the result is a null value. 9. TRUNCATE is faster than DELETE. 10. We can create a primary key constraint on column with Long Data type.

You might also like