0% found this document useful (0 votes)
14 views7 pages

SQL Mock Test 2 (81814)

The document contains a series of questions and answers related to SQL and database concepts, including table creation, constraints, aggregate functions, subqueries, and transaction management. It addresses common errors in SQL statements, the use of various SQL commands, and the properties of database relationships. Additionally, it explores the functionality of specific SQL features and the implications of using certain commands in Oracle databases.

Uploaded by

Harshad Bangar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

SQL Mock Test 2 (81814)

The document contains a series of questions and answers related to SQL and database concepts, including table creation, constraints, aggregate functions, subqueries, and transaction management. It addresses common errors in SQL statements, the use of various SQL commands, and the properties of database relationships. Additionally, it explores the functionality of specific SQL features and the implications of using certain commands in Oracle databases.

Uploaded by

Harshad Bangar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Q1).

You executed the following CreAtE TABLE statement that resulted in an error:
SOL> CREATE TABLE employees (emp_id NUMBER(10) PRIMARY KEY, ename VARCHAR2(20), email
NUMBER(3) UNIQUE, address VARCHAR2(500), phone VARCHAR2(20), resume LONG, hire date DATE,
remarks LONG, dept_id NUMBER(3) CONSTRAINT emp_dept_id_fk REFERENCES departments (dept_id) ,
CONSTRAINT ename_nn NOT NULL (ename));
Identify two reasons for the error.
A) The FOREIGN KEY keyword is missing in the constraint definition.
B) The Not NULL constraint on the ENAME column must be defined at the column level.
C) The PriMARY EY constraint in the EMP_ID column must have a name and must be defined at the table level
only.
D) FOREIGN key defined on the DEPT_ID column must be at the table level only.
E) Only one long column can be used per table.

Q.2)
Evaluate the following CREATE TABLE commands: CREATE_TABLE orders (ord_no NUMBER (2)
CONSTRAINT ord_pk PRIMARY KEY, ord_date DATE, cust_id NUMBER (4); CREATE TABLE ord_items (ord
_no NUMBER (2), item_no NUMBER(3), qty NUMBER (3) CHECK (qty BETWEÈÉn 100 ANd 200), expiry_date
date CHECK (expiry_date> SYSDATE), CONSTRAINT it_pk PRIMARY KEY (ord_no, itermn_no),
CONSTARAINT ord fk FOREIGN KEY (ord_no) REFERENCES orders (ord _no)'); why would the ORD_ITEMS
table not get created? Marks for correct answer: 1
Ans --
Evaluate the following CREATE TABLE commands:
CREATE TABLE orders
(ord_no NUMBER(2) CONSTRAINT ord_pk PRIMARY KEY,
ord_date DATE,
cust_id NUMBER(4));
CREATE TABLE ord_items
(ord_no NUMBER(2),
item_no NUMBER(3),
qty NUMBER(3) CHECK (qty BETWEEN 100 AND 200),
expiry_date date CHECK (expiry_date > SYSDATE),
CONSTRAINT it_pk PRIMARY KEY (ord_no,item_no),
CONSTRAINT ord_fk FOREIGN KEY(ord_no) REFERENCES orders(ord_no));
The above command fails when executed. What could be the reason?
A. SYSDATE cannot be used with the CHECK constraint.
B. The BETWEEN clause cannot be used for the CHECK constraint.
C. The CHECK constraint cannot be placed on columns having the DATE data type.
D. ORD_NO and ITEM_NO cannot be used as a composite primary key because ORD_NO is also
the FOREIGN KEY.
Answer: A

Q.3)
Which three statements are true about multiple-row subqueries?

A.They can contain a subquery within a subquery.


B.They can return multiple columns as well as rows.
C.They cannot contain a subquery within a subquery.
D.They can return only one column but multiple rows.
E.They can contain group functions and GROUP BY and HAVING clauses.
F.They can contain group functions and the GROUP BY clause, but not the HAVING clause.

Q4)
Examine the create table statements for the stores and sales tables.
SQL> CREATE TABLE stores(store_id NUMBER(4) CONSTRAINT store_id_pk PRIMARY KEY, store_name
VARCHAR2(12), store_address VARCHAR2(20), start_date DATE);
SQL> CREATE TABLE sales(sales_id NUMBER(4) CONSTRAINT sales_id_pk PRIMARY KEY, item_id
NUMBER(4), quantity NUMBER(10), sales_date DATE, store_id NUMBER(4),
CONSTRAINT store_id_fk FOREIGN KEY(store_id) REFERENCES stores(store_id));

You executed the following statement:


SQL> DELETE from stores
WHERE store_id=900;

The statement fails due to the integrity constraint error:


ORA-02292: integrity constraint (HR.STORE_ID_FK) violated

Which three options ensure that the statement will execute successfully?

A. Disable the primary key in the STORES table.


B. Use CASCADE keyword with DELETE statement.
C. DELETE the rows with STORE_ID = 900 from the SALES table and then delete rows from STORES table.
D. Disable the FOREIGN KEY in SALES table and then delete the rows.
E. Create the foreign key in the SALES table on SALES_ID column with on DELETE CASCADE option.
: Examine the create table statements for the stores and sales tables.
1. A,C,D

2. C,D,E
3. B,C,E

4. C,D,E
5. A,C,E

Q.5)
Which statement is true about aggregate functions?
The correct statement is C. The MAX and MIN functions can be used on columns with character data types.

A.Aggregate functions can be nested to any number of levels


B.The AVERAGE function implicitly convert NULL to zero
C.The MAX and MIN functions can be used on columns with character data types.
D.Aggregate functions can be used in any clause of a SELECT statement

6.Which two statements are true regarding the DELETE and TRUNCATE commands? (Choose two.)

Q.7)
Which three statements are true about multiple row subqueries? (Choose three.)
A. Two or more values are always returned from the subquery.
B. They can contain HAVING clauses.
C. They can contain GROUP BY clauses.
D. They can return multiple columns.
E. They cannot contain a subquery.

Q.8)
Which statement is true regarding the SESSION_PRIVS dictionary view?
Answer
A.It contains the current object privileges available in the user session.
B.It contains the current system privileges available in the user session.
C.It contains the object privileges granted to other users by the current user session.
D.It contains the system privileges granted to other users by the current user session.

Q.9) Which three are true about the MERGE statement? (Choose three.)
A. It can use subqueries to produce source rows..
B. It can update the same row of the target table multiple times.
C. It can update, insert, or delete rows conditionally in multiple tables.
D. It can use views to produce source rows
E. It can merge rows only from tables.
F. It can combine rows from multiple tables conditionally to insert into a single table

Q.10)
Which three are true about multitable INSERT statements? (Choose three.)
A. They can be performed on external tables using SQL*Loader.
B. They can be performed only by using a subquery.
C. They can be performed on views.
D. They can insert each computed row into more than one table.
E. They can be performed on remote tables.
F. They can be performed on relational tables.

Q.11)
Which three statements indicate the end of a transaction? (Choose three.)
In which three situations does a new transaction always start? (Choose three.)
A. when issuing a SELECT FOR UPDATE statement after a CREATE TABLE AS SELECT statement was issued
in the same session
B. when issuing a TRUNCATE statement after a SELECT statement was issued in the same session
C. when issuing a CREATE TABLE statement after a SELECT statement was issued in the same session
D. when issuing the first Data Manipulation Language (DML) statement after a COMMIT OR ROLLBACK
statement was issued in the same session
E. when issuing a CREATE INDEX statement after a CREATE TABLE statement completed successfully in the
same session
F. when issuing a DML statement after a DML statement failed in the same session

Q.12)
Which two statements are true regarding the WHERE and HAVING clauses in a SELECT statement? (Choose
two.)
A. WHERE and HAVING clauses can be used in the same statement only if applied to different table columns.
B. The WHERE clause can be used to exclude rows after dividing them into groups.
C. The HAVING clause can be used with aggregating functions in subqueries.
D. The WHERE clause can be used to exclude rows before dividing them into groups.
E. Aggregating functions and columns used in HAVING clauses must be specified in the SELECT list of a query.

Q.13) Which three statements are true about views in an Oracle Database?
A. A SELECT statement cannot contain a WHERE clause when querying a view containing a WHERE clause in
its defining query.
B. Views have no segment.
C. Views have no object number.
D. Views can join tables only if they belong to the same schema.
E. A view can be created that refers to a non-existent table in its defining query.
F. Rows inserted into a table using a view are retained in the table if the view is dropped.

Q.14)
You must write a query that prompts users for column names and conditions every time it is executed. The user
must be prompted only once for the table name. Which statement achieves those objectives?
A.SELECT &col1, &col2
FROM "&table"
WHERE &condition = &cond;
B. SELECT &col1, &col2
FROM &&table
WHERE &condition = &cond;
C. SELECT &col1, &col2
FROM &&table
SELECT &col1, '&col2'
FROM &table WHERE &&condition = '&cond';
Answer - B.

Q.15)
Which two are true about dropping columns from a table. (Choose 2)
A. A column must be set as unused before it is dropped from a table.
B. A primary key column cannot be dropped.
C. Multiple columns can be dropped simultaneously using the ALTER TABLE command.
D. A column can be removed only if it contains no data.
E. A column that is referenced by another column in any other table cannot be dropped.
F. A column drop is implicitly committed

Q.16)
What is the primary difference between the relational database (RDB) and object-oriented database (OODB)
models? Pending

Q.17)
Which three actions can you perform only with system privileges? (Choose three.)
A. Query any table in a database.
B. Execute a procedure in another schema.
C. Log in to a database instance.
D. Access flat files, which are stored in an operating system directory, via the UTL_FILE package.
E. Use the WITH GRANT OPTION clause.

Q.18
Which statement is true about Enterprise Manager (EM) Express?
A. You can use a single instance of EM Express to manage multiple database running on the same server.
B. EM Express uses a separate repository database to store target database metadata.
C. By default, EM express is available for a database after database creation using DBCA.
D. You can shut down a database instance using EM Express.
E. You cannot start up a database instance using EM Express.

Q.19) Which two statements are true about the COUNT function? (Choose two.)
A. COUNT(*) returns the number of rows in a table including duplicate rows and rows containing NULLs in any
column.
B. It can only be used for NUMBER data types.
C. COUNT(DISTINCT inv_amt) returns the number of rows excluding rows containing duplicates and NULLs in
the INV_AMT column.
D. COUNT(inv_amt) returns the number of rows in a table including rows with NULL in the INV_AMT column
E. A SELECT statement using the COUNT function with a DISTINCT keyword cannot have a WHERE clause.

Q.20)
You must create a table EMPLOYEES in which the values in the table
columns EMPLOYEES ID and LOGIN ID must be unique and not null. Which two SQL statements would create
the required

a.CREATE TABLE employees (


employee_id NUMBER(5) UNIQUE NOT NULL,
login_id VARCHAR2(30) UNIQUE NOT NULL,
first_name VARCHAR2(30),
last_name VARCHAR2(30)
);
B.CREATE TABLE employees (
employee_id NUMBER(5) NOT NULL,
login_id VARCHAR2(30) NOT NULL,
first_name VARCHAR2(30),
last_name VARCHAR2(30),
CONSTRAINT emp_id_uk UNIQUE (employee_id),
CONSTRAINT login_id_uk UNIQUE (login_id)
);

Q21) Which two statements are true? (Choose two.)

Q.22)
Which two statements are true regarding constraints? (Choose two.)
A. A constraint can be disabled even if the constraint column contains data
B. A constraint is enforced only for the INSERT operation on a table
C. A foreign key cannot contain NULL values
D. All constraints can be defined at the column level as well as the table level
E. A column with the UNIQUE constraint can contain NULL values

Q.23)
On your Oracle 12c database, you invoked SQL *Loader to load data into the EMPLOYEES table in the HR
schema by issuing the following command: $> sqlldr hr/hr@pdb table=employees Which two statements are true
regarding the command? (Choose two.)
A. It succeeds with default settings if the EMPLOYEES table belonging to HR is already defined in the database.
B. It fails because no SQL *Loader data file location is specified.
C. It fails if the HR user does not have the CREATE ANY DIRECTORY privilege.
D. It fails because no SQL *Loader control file location is specified.

Q.24)
In which three situations does a new transaction always start?
A. when issuing a CREATE TABLE statement after a SELECT statement was issued in the same session
B. when issuing a DML statement after a DML statement failed in the same session
C. when issuing the first Data Manipulation Language (DML) statement after a COMMIT OR ROLLBACK
statement was issued in the same session
D. when issuing a SELECT FOR UPDATE statement after a CREATE TABLE AS SELECT statement was issued
in the same session
E. when issuing a CREATE INDEX statement after a CREATE TABLE statement completed successfully in the
same session
F. when issuing a TRUNCATE statement after a SELECT statement was issued in the same session

Q.25)
You need to produce a report where each customera€'"s credit limit has been incremented by $1000. In the
output, the customerâe"" last name should have the heading Name and the incremented credit lirnit should be
labeled New Credit Limit. The column headings should have only the first letter of each word in uppercase, Which
statement would accomplish this requirement?

SELECT cust_last_name AS "Name", cust_credit_limit + 1000 AS "New Credit Limit" FROM customers;
SELECT cust_last_name AS "Name", credit_limit + 1000 AS "New Credit Limit" FROM customers;
0.26)
Which statement is true about the Oracle SQL, DELETE and TRUNCATE statements?

Q.27
Which statement is true regarding the UNION operator?
A..The number of columns selected in all SELECT statements need not to be the same
B.Names of all columns must be identical across all SELECT statements
C.By default, the output is not sorted
D.NULL values are not ignored during duplicate checking
Correct Answer -A

Q.28)
Examine the types and examples of relationship that follow: 1l One-to-one a) teacher to Student 2 One to-many
b) Employees to Manager 3 Many-to- one ) Person to SSN 4 Many-to-many d) Customers to Products. Which
option indicates correctly matched relationships?
1→c
2→a
3→b
4→d

You might also like