PostgreSQL Test

PostgreSQL Test

 

Choose the correct statement:

a. All PL/pgSQL expressions in a function, except dynamic queries, are only prepared once during the lifetime of the PostgreSQL backend process
b. All PL/pgSQL expressions in a function are only prepared once during the lifetime of the PostgreSQL backend process
c. All PL/pgSQL expressions in a function are prepared for each execution time during the lifetime of the PostgreSQL backend process
d. None of the above is correct


Premium Corp. uses alphanumeric characters for EmployeeID which contains 7 digits prefixed with 3 characters. The 3 characters describe the department code. You need to show the department code and the Employee number separately, where department code should be in capital letters. Which function(s) will you have to use for this?

a. CONCAT()
b. SUBSTR()
c. UPPER()
d. LOWER()
e. REPLACE()


What would happen on compiling and running the following function?

CREATE FUNCTION loop_function (integer) RETURNS integer AS ‘
DECLARE

result integer;

BEGIN

result := $1;

LOOP
result := result * result;
EXIT WHEN result >= 15000;
END LOOP;

RETURN result;
END;
‘ LANGUAGE ‘plpgsql’;

a. The function will not compile as the for loop defined is not syntactically correct
b. The function will not compile if the return parameter defined is not correct
c. The function will compile but will not give any output
d. The function will compile and will produce numeric output on running


Which of the following options can be used to create and initialize a new database cluster within your file system?

a. initdbcluster
b. createcluster
c. initdb
d. createdb_cluster


Which of the following date function(s) are invalid?

a. NEXT_DAY
b. NEXT_MONTH
c. MONTHS_BETWEEN
d. DAYS_BETWEEN
e. None of above


Which of the following statements are true for ordinary views?

a. A view is stored in the data dictionary
b. Views provide a more secure way of data retrieval
c. Views are actual tables and store data at another location
d. All of the above are true


A handler named ‘plpgsqlHandle()’ is created for installing PL/pgSQL. For creating the handler on ‘SwineDB’ database you would issue a command:

a. SwineDB=# CREATE LANGUAGE ‘pl/pgsql’ HANDLER plpgsqlHandle
    SwineDB-#                           LANCOMPILER ‘Install PL/pgSQL’;
    CREATE
b. SwineDB=# CREATE LANGUAGE ‘pl/pgsql’ EXECUTE plpgsqlHandle
    SwineDB-#                           LANCOMPILER ‘Install PL/pgSQL’;
    CREATE
c. SwineDB=# CREATE LANGUAGE ‘plpgsql’ HANDLER plpgsqlHandle
    SwineDB-#                           LANCOMPILER ‘Install PL/pgSQL’;
    CREATE
d. SwineDB=# CREATE LANGUAGE ‘plpgsql’ EXECUTE plpgsqlHandle
    SwineDB-#                           LANCOMPILER ‘Install PL/pgSQL’;
    CREATE


Which of the following statements are incorrect regarding referential integrity?

a. A foreign key can refer to a primary key
b. A foreign key can refer to a unique key
c. The on delete cascade clause will work only if there is a reference to a primary key
d. The referred key can either be in the same table or in some other table
e. A foreign key can be composite
f. Referential integrity can only be applied while creating the table


Prev1 of 5

Share This Post

Post Comment