PostgreSQL MCQ

 PostgreSQL MCQ

PostgreSQL MCQ : This PostgreSQL Beginner Quiz contains set of 60 PostgreSQL Quiz which will help to clear any Mcqs exam which is designed for Beginner.

Topics covered – PostgreSQL, postgres, databases postgres, postgres databases, what is postgresql, database postgresql, postgres database, postgresql database, postgres version, postgresql version, db postgres, postgresql db, db postgresql, postgres db, postgres server, postgresql server, latest postgres version, postgresql in and so on.



1) Which command  is used to the list of databases?

  1. \d
  2. \l
  3. \db
  4. \ld
Answer : B

 

 

2) which command is used to  connect/select a database

  1. \l <dbnam>
  2. \cd <dbname>
  3. \s <dbname>
  4. \c <dbname>
Answer : D

 

 

3) Which command list down all the tables in an attached database.

  1. \db
  2. \c
  3. \d
  4. \l
Answer : C

 

 

4) \d tablename command

  1. lists the table
  2. lists all the tables in the database
  3. describes the structure of the table
  4. this is not a valid command
Answer : C

 

 

5) A_________ is a named collection of tables.

  1. database
  2. table
  3. macro
  4. schema
Answer : D

 

 

6) which statement about the where clause is true?

  1. WHERE clause is used to specify a condition while fetching the data
  2. it returns only the records that’s satisfies the condition
  3. WHERE clause can be used in UPDATE and DELETE statements
  4. All of the Above
Answer : D

 

 

7) what does the following query do?  SELECT * FROM CUSTOMER LIMIT 3 OFFSET 2;

  1. picks up three records
  2. picks up three records starting from the second position
  3. picks up second and third record
  4. throws an error
Answer : B

 

 

8) which command is used to  list indexes available on CUSTOMER table

  1. \show CUSTOMER
  2. \indexes CUSTOMER
  3. \i CUSTOMER
  4. \d CUSTOMER
Answer : D

 

 

9) which command is used to select the  customer who has been spending more than 200

  1. SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id WHERE  amount > 200;
  2. SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id WHERE  SUM (amount) > 200;
  3. SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id WHERE  SUM (amount) > 200;
  4. SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id  HAVING amount > 200;
Answer : C

 

 

10) Which operator performs pattern matching?

  1. Like
  2. Between
  3. In
  4. Exists
Answer : A

 

 

11) What type of join is used when you want to use a join between columns that are in the same table?

  1. SELF
  2. EQUI
  3. OUTER
  4. CROSS
Answer : A

 

 

12) The basic psql command to list tables is?

  1. \dT
  2. \dt
  3. \do
  4. \h
Answer : B

 

 

13) The most common method to get data into a table is to use what command?

  1. Write
  2. Insert
  3. Execute
  4. Send
Answer : B

 

 

14) PostgreSQL is

  1. a relational database management system.
  2. a hierarchical database management system.
  3. a network-type database management system.
  4. an XML database management system.
Answer : A

 

 

15) PostgreSQL runs on

  1. all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows.
  2. on all UNIX versions except Solaris.
  3. Linux and Windows only.
  4. Windows only
Answer : A

 

 

16) What command tells PostgreSQL that all of the changes you made to a database should become permanent?

  1. Apply
  2. Execute
  3. Commit
  4. Send
Answer : C

 

 

17) ____________ allow us to define formally in the database how different tables relate to each other.

  1. Views
  2. Temporary tables
  3. Foreign key constraints
  4. Table management
Answer : C

 

 

18) If you don’t specify ASC or DESC, PostgreSQL will assume you want to see results:

  1. in ascending order
  2. grouped together by field type
  3. in a random order
  4. in descending order
Answer : A

 

 

19) The value NULL, in database terminology, means?

  1. The value is undetermined at this time
  2. The value is undetermined
  3. The value is not relevant for this particular row.
  4. All of the Above
Answer : D

 

 

20) What does the following statement do? CREATE INDEX lower_title_idx ON books ((lower(title)));

  1. Modifies an index in place to be lowercase
  2. Creates a new index with a special operator class ‘lower’ for case insensitive comparisons
  3. Creates an index for efficient case-insensitive searches on the titles column within the books table
  4. Nothing, it’s invalid SQL
Answer : C

 

 

21) which command is used to supress the duplicate records?

  1. distinct
  2. duplicate
  3. supress
  4. hide
Answer : A

 

 

22) Which of the following is not true about inserting news rows to a table?

  1. INSERT statement is use for inserting new rows into the table
  2. You cannot insert rows with NULL values in a table
  3. you many insert a new row containing values for each column
  4. you can ignore sore columns while insertuing the rows in a table
Answer : D

 

 

23) which of the following command is used o modify a SEQUNCE

  1. ALTER SEQUENCE
  2. SELECT SEQUENCE
  3. DROP SEQUENCE
  4. MODIFY SEQUENCE
Answer : A

 

 

24) what is returned by ROUND(789.8379,2)?

  1. 84
  2. 83
  3. 78
  4. 789
Answer : A

 

 

25) which of the following is not  true about  creating CONSTRAINTS?

  1. constraints are defined using CREATE CONSTRAINT command
  2. they are created at the same time when table is created
  3. they should be created after the table is created
  4. all the constrains are stored in data dict
Answer : C

 

 

26) which of the following is true about Cartesian product?

  1. is formed when a join condition is ommited
  2. A Cartesian product is formed when a join condition is valid.
  3. Some rows in the first table are joined to all rows in the second table
  4. All rows in the first table are joined to some rows in the second table.
Answer : A

 

 

27) Which of the following is true about a group function?

  1. Group functions operate on set of rows to produce multiple results per group
  2. Group functions ignore NULL values
  3. DISTINCT keyword makes a group function consider duplicate values
  4. None of the above
Answer : B

 

 

28) Which of the following is not true about the COALESCE function?

  1. It returns the first NON-NULL expression in the parameter list
  2. It takes multiple alternate values
  3. It returns the first value in the parameter if it is NULL
  4. None of the above
Answer : C

 

 

29) In which of the following cases a DML statement is executed?

  1. When a table is created
  2. When a Transaction is committed
  3. When new rows are added to a table
  4. None of the above
Answer : C

 

 

30) Consider the schema:                            STUDENTS(student_code, first_name, last_name)                     Which of the following query will display all the students where the second letter in the first_name is ‘a’ ?

  1. select first_name from students where first_name like ‘_a%’;
  2. select first_name from students where first_name like ‘%a_’;
  3. select first_name from students where first_name like ‘%a%’;
  4. select first_name from students where first_name like ‘_a_’;
Answer : A

 

 

31) Consider the schema:                            STUDENTS(student_code, first_name, last_name,email)         Which of the following query would display names of all the students whose email ids are not provided?

  1. select first_name , last_name from students where email=0;
  2. select first_name , last_name from students where email=’ ‘;
  3. select first_name , last_name from students where email=’NULL’ ;
  4. select first_name , last_name from students where email is NULL
Answer : D

 

 

32) Which of the following is not a character manipulation function?

  1. CONCAT
  2. INSTR
  3. SUBSTR
  4. COALESCE
Answer : D

 

 

33) What is returned by INSTR‘WIPROLIMITED ′ , ‘P ′?

  1. 3
  2. 2
  3. WIPRO
  4. LIMITED
Answer : A

 

 

34) What is returned by SUBSTR(‘WIPRO LIMITED ′,1,6)

  1. WIPRO
  2. WIPROL
  3. IPRO L
  4. IPROLI
Answer : A

 

 

35) What is returned by SUBSTR(‘WIPRO LIMITED ′,-1,1)

  1. NULL
  2. 0
  3. D
  4. E
Answer : C

 

 

36) Which of the following is not a group function?

  1. SUM
  2. NVL
  3. COUNT
  4. MIN
Answer : B

 

 

37) Which of the following functions can be used on both numeric as well as nonnumeric data?

  1. SUM
  2. AVG
  3. COUNT
  4. VARIANCE
Answer : C

 

 

38) Which of the following is not true about the MAX and MIN functions?

  1. Both can be used for any data type.
  2. MAX returns the maximum value
  3. MIN returns the minimum value.
  4. Both works only with Numeric datatype
Answer : D

 

 

39) A subquery can be placed in which of the SQL clauses?

  1. The WHERE clause
  2. The HAVING clause
  3. The FROM clause
  4. All of the above
Answer : D

 

 

40) Which of the following comparison operators could be used in a multiple row query?

  1. IN
  2. ANY
  3. ALL
  4. All of the Above
Answer : D

 

 

41) which SQL statement is used to extract data from the table?

  1. OPEN
  2. SELECT
  3. GET
  4. EXTRACT
Answer : B

 

 

42) With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” is “Lakshmi”?

  1. SELECT [all] FROM Persons WHERE FirstName=’Lakshmi’
  2. SELECT [all] FROM Persons WHERE FirstName LIKE ‘Lakshmi’
  3. SELECT * FROM Persons WHERE FirstName<>’Lakshmi’
  4. SELECT * FROM Persons WHERE FirstName=’Lakshmi’
Answer : D

 

 

43) which SQL keyword is used to sort the result-set

  1. SORT
  2. ORDER
  3. SORT BY
  4. ORDER BY
Answer : D

 

 

44) With SQL, how can you return all the records from a table named “Persons” sorted descending by “FirstName”?

  1. SELECT * FROM Persons ORDER FirstName DESC
  2. SELECT * FROM Persons ORDER BY FirstName DESC
  3. SELECT * FROM Persons SORT BY ‘FirstName’ DESC
  4. SELECT * FROM Persons SORT ‘FirstName’ DESC
Answer : B

 

 

45) With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?

  1. INSERT (‘Olsen’) INTO Persons (LastName)
  2. INSERT INTO Persons (‘Olsen’) INTO LastName
  3. INSERT INTO Persons (LastName) VALUES (‘Olsen’)
  4. INSERT INTO Persons (LastName) (‘Olsen’)
Answer : C

 

 

46) How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?

  1. MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen
  2. MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
  3. UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
  4. UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
Answer : D

 

 

47) With SQL, how can you delete the records where the “FirstName” is “Peter” in the Persons Table?

  1. DELETE FirstName=’Peter’ FROM Persons
  2. DELETE ROW FirstName=’Peter’ FROM Person
  3. DELETE FROM Persons WHERE FirstName = ‘Peter’
  4. DELETE FROM Persons WHERE FirstName is ‘Peter’
Answer : C

 

 

48) What is the most common type of join?

  1. INNER
  2. SELF
  3. FULL OUTER
  4. EXPLICIT
Answer : A

 

 

49) Which operator is used to select values within a range?

  1. RANGE
  2. WITHIN
  3. BETWEEN
  4. IN
Answer : C

 

 

50) What is True about Indexes?

  1. Indexes should not be used on a smaller table
  2. Indexes should not be created on a column that contain more of NULL values
  3. Indexes should not be used on a table that is updated frequently
  4. All of the Above
Answer : D

 

 

51) how to create an Index on salary column of Customer table?

  1. Create Index salary_index on Customer(salary)
  2. Create Index on    Customer(salary)
  3. Create Index salary_index using Customer(salary)
  4. Create Index salary_index on salary of customer
Answer : A

 

 

52) What does the following statement do? CREATE INDEX lower_title_idx ON books ((lower(title)));

  1. Modifies an index in place to be lowercase
  2. Creates a new index with a special operator class ‘lower’ for case insensitive comparisons.
  3. Creates an index for efficient case-insensitive searches on the titles column within the books table
  4. Nothing, it’s invalid SQL
Answer : C

 

 

53) The syntax to view the indexes of an existing postgreSQL table is :

  1. index database_name.table_name
  2. \d table_name
  3. \i table_name
  4. index table_name
Answer : B

 

 

54) Which SQL statement is used to delete records from a table?

  1. DELETE
  2. COLLAPSE
  3. REMOVE
  4. DROP
Answer : A

 

 

55) CREATE vwEmployee VIEW  AS  SELECT * FROM Employee WHERE ID < 100                                              choose the correct option

  1. View name must be after keyword view
  2. replace column name instead of *
  3. VIEW is an optional keyword
  4. there is no error in the query
Answer : A

 

 

56) Views are also called as:

  1. Complex tables
  2. Simple tables
  3. Virtual tables
  4. Actual Tables
Answer : C

 

 

57) What is true about views among all the given below statements:

  1. View never references actual table for which it is created.
  2. View can’t use JOIN in it’s query.
  3. The performance of the view degrades if they are based on other views
  4. Only option to safeguard data integrity.
Answer : C

 

 

58) Which category Delete query exits?

  1. DDL
  2. DML
  3. TCL
  4. DQL
Answer : B

 

 

59) Which one is correct syntax for Where clause

  1. SELECT WHERE “Condition” Col1, Col2 FROM “Table” ;
  2. SELECT “Condition” Col1, Col2 FROM “Table” WHERE;
  3. SELECT Col1, Col2 FROM “Table” WHERE “condition”;
  4. None of the above
Answer : C