teste-5-8

January 25, 2019 | Author: Veronica Perjeru | Category: Database Index, Database Transaction, Table (Database), Subroutine, Databases
Share Embed Donate


Short Description

MySQL...

Description

TEST 5

1. Given an SQL table named t  having  having a column of type INT named c  and  and the contents below, what will the following f ollowing query produce?

SELECT COUNT(c) FROM t GROUP BY c; a.

four records, having the values of NULL,8,2 and 6

b.

one record having a value of 6

c.

three records, having the values of 8, 2 and 6

d.

three records, having the values of 2, 1 and 1

e.

four records, having the values of 0,1,1 and 2

f.

one record having a value of 4

E 2. Given a populated populated SQL table having having the definition below, what what will the SELECT query produce? CREATE TABLE Shopping(ProductName VARCHAR(100), Category VARCHAR(100), Date DATETIME); SELECT Category, Date, COUNT(DISTINCT ProductName) AS nr FROM Shopping WHERE Date>(CURRENT_DATEINTERVAL 7 DAY) GROUP BY Date, Category HAVING nr>1; a.

the number of different products bought from each category every day in the last 7 days, only if more than one product from that category has been bought that day

b.

the number of different products bought from each category more than 7 days ago, if that category includes at least 2 products

c. d.  A

the number of products bought from each category starting 7 days ago the number of different products bought each day for dates older than a week ago, only if more than one product from each category has been bought that day

3. Which of the following are true regarding NULL values in MySQL expressions? (choose three) a.

the = operator can be used for testing if one of its operands is NULL

b.

the operator will return 1 if any of its operands is NULL

c.

most operators return 0 when one of the operands is NULL

d.

when testing if an expression evaluates as NULL, the IS NULL or IS NOT NULL operators may be used

e.

most operators return NULL when one of the operands is NULL

f.

the operator will return 1 if both operands are NULL

DEF 4. What

possible

values

may

the

following

MySQL

expression

produce?

 ABS(FLOOR(RAND()*INTERVAL(34.2, 17, 21, 56, 69))-ROUND(0.0156,2)*100) ABS(FLOOR(RAND()*INTERVAL(34.2, 69))-ROUND(0.0156,2)*100)CEIL(PI())/2 a.

0, 1 or 2

b.

1 or 2

c.

0 or 1

d.

0, 1 or -1

e.

0 or -1

E 5. What will be the value value of the MySQL expression expression s1 = s2  if  if column s1 has the value 'Test' and column s2  has  has the value 'TEST'?

D

a.

1

b.

NULL

c.

the = operator can't take column name as operands

d.

depends on the charset and collation of the columns

e.

0

6. Which of the following are valid ways of representing an integer value of 161 inside a MySQL expression? (choose four) a.

`161`

b.

161

c.

0xA1

d.

x'A1'

e.

xA1

f.

X'A1'

BCDF 7. Which of the following MySQL expressions will evaluate as yesterday's date? a.

TODAY – INTERVAL 24 HOUR

b.

CURRENT_DATE – INTERVAL 1 DAY

c.

CURRENT_DATE - INTERVAL 24 HOURS

d.

CURRENT_DATE - 24 HOUR

e.

NOW - 1 DAYS

f.

CURRENT_DATE – 1 DAY INTERVAL

B 8. What value will be inserted on the Year column when executing the statements below on a MySQL server? CREATE TABLE Dates(Year YEAR(4) NOT NULL); INSERT INTO Dates VALUES(2);

 A

a.

2002

b.

2

c.

1902

d.

0000, because the inserted value is not valid

9. Given an SQL table named People, having 10 records, and the two SELECT statements below that operate on a column named Weight from that table, which of the following is NOT true? SELECT FLOOR(Weight) FROM People; SELECT AVG(Weight) FROM People; a.

the first query will return a result set containing 10 records

b.

the second query uses an aggregate function

c.

the FLOOR() function will be called 10 times – once for each record

d.

the AVG() function will be called 10 times – once for each record

e.

the second query will return a result set containing 1 record

D 10. Which of the following are MySQL aggregate functions? (choose two) a.

INSTR()

b.

MIN()

c.

LPAD()

d.

CONCAT_WS()

e.

AVG()

f.

LEAST()

BE 11. After the table having the definition below has been populated with data, which of the following SELECT statements will NOT produce the same result as the others? CREATE TABLE Numbers (nr ENUM ('zero','one','two','three'));

B

a.

SELECT * FROM Numbers WHERE nr>1 AND nr50000 WITH CHECK OPTION; a.

INSERT INTO bigcities VALUES('Bucharest',2000000);

b.

DELETE FROM bigcities WHERE Name='Timisoara'

c.

UPDATE bigcities SET Population=Population+1;

d.

INSERT INTO bigcities VALUES('Voluntari',30000);

e.

UPDATE bigcities SET Name='Bucuresti' WHERE Name='Bucharest'

D 5. Given the variable definition below, which of the following correctly creates a prepared statement named st ? (choose two) SET @q = 'SELECT * FROM Products WHERE productID=?' a.

PREPARE st SELECT * FROM Products WHERE productID=?

b.

PREPARE st FROM '@q'

c.

PREPARE st FROM 'SELECT * FROM Products WHERE productID=?'

d.

PREPARE st FROM SELECT * FROM Products WHERE productID=?

e.

PREPARE st FROM @q

f.

PREPARE st AS SELECT * FROM Products WHERE productID=?

CE 6. Given the MySQL variable defined using the statement below, which of the following SQL statements shows an incorrect use of this variable? @a = 5;

 A

a.

SELECT * FROM Products LIMIT @a

b.

SELECT * FROM Products WHERE Price>@a

c.

SET @b = @a+1

d.

INSERT INTO Products(Price) VALUES(@a)

e.

SELECT SQRT(@a)

7. If a MySQL client has an ongoing transaction with a MySQL server, which actions of the client will make the changes made so far permanent? (choose four) a.

the client starts a new transaction

b.

the client sets autocommit to 1

c.

the client disconnects

d.

the client executes COMMIT

e.

the client executes ROLLBACK

f.

the client executes a DDL statement

 ABDF 8. Which of the following SQL statements allows the client to obtain the list of views defined in the current database? a.

SHOW TABLES

b.

SHOW VIEWS

c.

SHOW FULL TABLES

d.

DESCRIBE VIEWS

e.

SHOW CREATE VIEWS

C 9. Which of the following operators can be used for assigning a value to a MySQL user-defined variable? (choose two)

CE

a.

:

b.

=:

c.

=

d.

==

e.

:=

10. Which of the following SQL statements correctly defines an SQL view? a.

CREATE VIEW Laptops FROM 'SELECT * FROM Computers WHERE computer_type=laptop'

b.

CREATE VIEW Laptops AS 'SELECT * FROM Computers WHERE computer_type=laptop'

c.

CREATE VIEW Laptops(*) AS SELECT * FROM Computers WHERE computer_type='laptop'

d.

CREATE VIEW computer_type=laptop

e.

CREATE VIEW Laptops computer_type='laptop'

Laptops

SELECT AS

*

SELECT *

FROM FROM

Computers

WHERE

Computers WHERE

E 11. What will be the values of variables @a and @b after the following set of SQL statements executes? SET @a=5; SET @b=@a+1; SELECT @a=6,@a:=@a+@b,@b=8; a.

12 and 8

b.

11 and 6

c.

11 and 8

d.

12 and 6

B 12. Which of the following is true about MySQL transactions? a.

rolling back a transaction will undo all changes made by all the server's clients since starting the transaction

b.

committing a transaction will undo all changes made by the client who started it since the beginning of the transaction

c.

E

if a client starts a transaction, any other client will be able to roll it back

d.

rolling back a transaction will undo all changes made by the client who initiated it since the start of the client's MySQL session

e.

a transaction is a set of SQL statements that execute atomically (either all of them succeed or they do not modify data)

13. SQL views can be used for: (choose three) a.

storing useful predefined queries in the database, that act as virtual tables

b.

gradually changing the structure of a database while maintaining compatibility with current client applications

c.

atomically executing sets of SQL statements, with the possibility of rolling them back in case of error

d.

defining precompiled queries that can be later executed using various sets of input parameters

e.

restricting the columns and/or rows of an SQL table that a client can access

 ABE 14. Which of the following is a precompiled query defined by the client that can be later executed repeatedly with various input parameters? a.

transaction

b.

prepared statement

c.

user variable

d.

view

B 15. Which of the following types of query can be used for defining an SQL view? a.

UPDATE

b.

SELECT

c.

DELETE

d.

INSERT

B 16. Which of the following are true regarding MySQL client-defined (session) variables? (choose two)

 AC

a.

variable names are case insensitive starting with MySQL 5.0

b.

variable names must not contain digits

c.

variable names must be preceded by @

d.

variable names must be preceded by $

e.

all variable names must be enclosed in double quotes

17. When creating an SQL view, which of the following will prevent the view from being updatable? (choose four) a.

using aggregation functions in the SELECT statement that defines the view

b.

creating a one-to-one relationship between the rows in the view and the rows in the base table

c.

defining a view that only contains derived columns (calculated using expressions)

d.

using the MERGE algorithm

e.

using DISTINCT in the SELECT statement that defines the view

f.

using the TEMPTABLE algorithm

 ACEF 18. Which of the following statements will show the list of columns that a view produces? (choose three) a.

SHOW FULL TABLES LIKE 'viewname'

b.

DESCRIBE viewname

c.

SHOW VIEW viewname

d.

SHOW CREATE VIEW viewname

e.

SHOW CREATE TABLE viewname

BDE TEST 8

1. When executing the set of statements below using the mysql  client, what will the CALL statement produce? DELIMITER $ SET @a=2; CREATE PROCEDURE p(IN id INT) BEGIN SELECT Name FROM Products WHERE productID=id INTO @b; END$ CALL p(@a);

E

a.

an error, because procedures are not executed using CALL

b.

a result set, because the procedure is using a SELECT statement

c.

NULL, because the procedure doesn't have a RETURN statement

d.

an error, because procedures are not allowed to produce result sets

e.

nothing, because it is using the wrong delimiter and it won't be executed

2. What will be the value of @b after SET @a=10; DELIMITER $ CREATE PROCEDURE p(IN x INT) BEGIN SET x=4; SET @b = @a; END$ CALL p(@a)$ a.

10

b.

0

c.

4

d.

NULL

executing

the

statements

below?

 A 3. What is true about the following stored procedure definition? CREATE PROCEDURE proc() SELECT * FROM Products; a. b.

the definition is invalid because the procedure has no RETURNS clause the definition is invalid because the procedure is not declared as DETERMINISTIC or NOT DETERMINISTIC

c.

the definition is invalid because a procedure may not produce a result set

d.

the definition is invalid because the procedure has no input parameters

e.

the definition is correct

f.

the definition is invalid because it is missing the algorithm

E 4. What is wrong with the following stored function definition? (choose two) CREATE FUNCTION test() DECLARE var INT; SELECT Name FROM Products LIMIT 1 INTO var;

BC

a.

it is missing the set of input parameters

b.

it is missing the BEGIN...END statement block delimiters

c.

it is missing the RETURNS clause and the RETURN statement

d.

variables can only be assigned with SET, not with SELECT...INTO

e.

it is missing the default value for the var  variable

5. In MySQL stored routines, a condition is: a.

a set of SQL statements run periodically by the database server

b.

a certain type of error that can appear inside the routine

c.

a set of SQL statements that is run when an error appears inside a stored routine

d.

a set of SQL statements that is run when a table's data is modified

B 6. Which of the following types of SQL code stored on the server is attached to a table and run automatically when table data is modified? a.

trigger

b.

stored function

c.

stored procedure

d.

event

 A 7. Which of the following are true about a MySQL stored function? (choose three) a. b.

it can produce more than one output value it can be executed by simply using its name and a possible list of parameter values

c.

it can be executed using the CALL statement

d.

it returns exactly one value

e.

it can produce a result set

f.

it can only have parameters of type IN

BDF 8. Which of the following SQL statements can be used for forcefully exiting a labeled BEGIN...END block inside a stored procedure?

 A

a.

LEAVE

b.

REPEAT

c.

LOOP

d.

RETURNS

9. Which of the following is a valid use of a MySQL flow control construct? a.

LOOP SET @var=@var+1; END LOOP;

b.

LOOP @var4 SET @var:=@var+1; DONE;

e.

WHILE @var>4 THEN SET @var:=@var+1; END WHILE

 A 10. A MySQL trigger can be automatically executed for which of the following types of SQL statements? (choose three) a.

TRUNCATE

b.

DROP

c.

SELECT

d.

UPDATE

e.

DELETE

f.

INSERT

DEF 11. Which of the following are true about a MySQL stored procedure? (choose three) a.

it can produce more than one output value

b.

it can be executed using the EXECUTE statement

c.

it returns exactly one value

d.

it can be executed using the CALL statement

e.

it can only have parameters of type IN

f.

it can produce a result set

 ADF

12. All of the following are true about MySQL local variables, EXCEPT: a.

local variables declared inside a stored routine will remain available after the execution of the stored routine ends

b.

local variables can be declared using the DECLARE statement

c.

local variables must be declared before use

d.

local variable names are not preceded with @

e.

all local variables must be declared at the beginning of the stored routine, before declaring any cursors, conditions or handlers

f.

multiple local variables may be declared using a single DECLARE statement, but they will all have the same type and default value

 A 13. A MySQL cursor is used for: a.

accessing the rows of a result set from inside a stored routine

b.

automatically executing SQL code when table data is being modified

c.

periodically executing a set of SQL statements in the database

d.

reacting to certain types of errors that appear inside a stored routine

 A 14. What is the value of @var  after executing the following set of SQL statements? SET @var = 0; CASE @var+10 WHEN 0 THEN SET @var=10; WHEN 10 THEN SET @var = 20; WHEN 20 THEN SET @var = 30; ELSE SET @var = 40; END CASE;

C

a.

40

b.

10

c.

20

d.

30

15. A MySQL condition can be identified by its: (choose two) a.

attached cursor

b.

MySQL error code

c.

attached handler name

d.

SQLSTATE code

BD 16. Choose the answer that corresponds to the correct order of DECLARE statements inside a MySQL stored routine: a. handlers b. variables c. cursors d. conditions a.

a,b,c,d

b.

b,d,c,a

c.

c,d,b,a

d.

d,b,c,a

B 17.What types of parameters may a MySQL stored procedure have? (choose three) a.

INOUT

b.

RETURN

c.

OUT

d.

RETURNS

e.

IN

 ACE 18.Which of the following MySQL flow-control constructs are used for repeatedly executing a set of SQL statements? (choose three) a.

CASE

b.

LOOP

c.

IF

d.

REPEAT

e. BDE

WHILE

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF