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?
- \d
- \l
- \db
- \ld
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
2) which command is used to connect/select a database
- \l <dbnam>
- \cd <dbname>
- \s <dbname>
- \c <dbname>
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
3) Which command list down all the tables in an attached database.
- \db
- \c
- \d
- \l
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
4) \d tablename command
- lists the table
- lists all the tables in the database
- describes the structure of the table
- this is not a valid command
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
5) A_________ is a named collection of tables.
- database
- table
- macro
- schema
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
6) which statement about the where clause is true?
- WHERE clause is used to specify a condition while fetching the data
- it returns only the records that’s satisfies the condition
- WHERE clause can be used in UPDATE and DELETE statements
- All of the Above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
7) what does the following query do? SELECT * FROM CUSTOMER LIMIT 3 OFFSET 2;
- picks up three records
- picks up three records starting from the second position
- picks up second and third record
- throws an error
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
8) which command is used to list indexes available on CUSTOMER table
- \show CUSTOMER
- \indexes CUSTOMER
- \i CUSTOMER
- \d CUSTOMER
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
9) which command is used to select the customer who has been spending more than 200
- SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id WHERE amount > 200;
- SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id WHERE SUM (amount) > 200;
- SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id WHERE SUM (amount) > 200;
- SELECT customer_id, SUM (amount) FROM payment GROUP BY customer_id HAVING amount > 200;
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
10) Which operator performs pattern matching?
- Like
- Between
- In
- Exists
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
11) What type of join is used when you want to use a join between columns that are in the same table?
- SELF
- EQUI
- OUTER
- CROSS
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
12) The basic psql command to list tables is?
- \dT
- \dt
- \do
- \h
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
13) The most common method to get data into a table is to use what command?
- Write
- Insert
- Execute
- Send
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
14) PostgreSQL is
- a relational database management system.
- a hierarchical database management system.
- a network-type database management system.
- an XML database management system.
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
15) PostgreSQL runs on
- all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows.
- on all UNIX versions except Solaris.
- Linux and Windows only.
- Windows only
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
16) What command tells PostgreSQL that all of the changes you made to a database should become permanent?
- Apply
- Execute
- Commit
- Send
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
17) ____________ allow us to define formally in the database how different tables relate to each other.
- Views
- Temporary tables
- Foreign key constraints
- Table management
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
18) If you don’t specify ASC or DESC, PostgreSQL will assume you want to see results:
- in ascending order
- grouped together by field type
- in a random order
- in descending order
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
19) The value NULL, in database terminology, means?
- The value is undetermined at this time
- The value is undetermined
- The value is not relevant for this particular row.
- All of the Above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
20) What does the following statement do? CREATE INDEX lower_title_idx ON books ((lower(title)));
- Modifies an index in place to be lowercase
- Creates a new index with a special operator class ‘lower’ for case insensitive comparisons
- Creates an index for efficient case-insensitive searches on the titles column within the books table
- Nothing, it’s invalid SQL
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
21) which command is used to supress the duplicate records?
- distinct
- duplicate
- supress
- hide
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
22) Which of the following is not true about inserting news rows to a table?
- INSERT statement is use for inserting new rows into the table
- You cannot insert rows with NULL values in a table
- you many insert a new row containing values for each column
- you can ignore sore columns while insertuing the rows in a table
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
23) which of the following command is used o modify a SEQUNCE
- ALTER SEQUENCE
- SELECT SEQUENCE
- DROP SEQUENCE
- MODIFY SEQUENCE
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
24) what is returned by ROUND(789.8379,2)?
- 84
- 83
- 78
- 789
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
25) which of the following is not true about creating CONSTRAINTS?
- constraints are defined using CREATE CONSTRAINT command
- they are created at the same time when table is created
- they should be created after the table is created
- all the constrains are stored in data dict
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
26) which of the following is true about Cartesian product?
- is formed when a join condition is ommited
- A Cartesian product is formed when a join condition is valid.
- Some rows in the first table are joined to all rows in the second table
- All rows in the first table are joined to some rows in the second table.
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
27) Which of the following is true about a group function?
- Group functions operate on set of rows to produce multiple results per group
- Group functions ignore NULL values
- DISTINCT keyword makes a group function consider duplicate values
- None of the above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
28) Which of the following is not true about the COALESCE function?
- It returns the first NON-NULL expression in the parameter list
- It takes multiple alternate values
- It returns the first value in the parameter if it is NULL
- None of the above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
29) In which of the following cases a DML statement is executed?
- When a table is created
- When a Transaction is committed
- When new rows are added to a table
- None of the above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
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’ ?
- select first_name from students where first_name like ‘_a%’;
- select first_name from students where first_name like ‘%a_’;
- select first_name from students where first_name like ‘%a%’;
- select first_name from students where first_name like ‘_a_’;
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
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?
- select first_name , last_name from students where email=0;
- select first_name , last_name from students where email=’ ‘;
- select first_name , last_name from students where email=’NULL’ ;
- select first_name , last_name from students where email is NULL
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
32) Which of the following is not a character manipulation function?
- CONCAT
- INSTR
- SUBSTR
- COALESCE
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
33) What is returned by INSTR‘WIPROLIMITED ′ , ‘P ′?
- 3
- 2
- WIPRO
- LIMITED
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
34) What is returned by SUBSTR(‘WIPRO LIMITED ′,1,6)
- WIPRO
- WIPROL
- IPRO L
- IPROLI
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
35) What is returned by SUBSTR(‘WIPRO LIMITED ′,-1,1)
- NULL
- 0
- D
- E
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
36) Which of the following is not a group function?
- SUM
- NVL
- COUNT
- MIN
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
37) Which of the following functions can be used on both numeric as well as nonnumeric data?
- SUM
- AVG
- COUNT
- VARIANCE
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
38) Which of the following is not true about the MAX and MIN functions?
- Both can be used for any data type.
- MAX returns the maximum value
- MIN returns the minimum value.
- Both works only with Numeric datatype
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
39) A subquery can be placed in which of the SQL clauses?
- The WHERE clause
- The HAVING clause
- The FROM clause
- All of the above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
40) Which of the following comparison operators could be used in a multiple row query?
- IN
- ANY
- ALL
- All of the Above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
41) which SQL statement is used to extract data from the table?
- OPEN
- SELECT
- GET
- EXTRACT
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
42) With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” is “Lakshmi”?
- SELECT [all] FROM Persons WHERE FirstName=’Lakshmi’
- SELECT [all] FROM Persons WHERE FirstName LIKE ‘Lakshmi’
- SELECT * FROM Persons WHERE FirstName<>’Lakshmi’
- SELECT * FROM Persons WHERE FirstName=’Lakshmi’
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
43) which SQL keyword is used to sort the result-set
- SORT
- ORDER
- SORT BY
- ORDER BY
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
44) With SQL, how can you return all the records from a table named “Persons” sorted descending by “FirstName”?
- SELECT * FROM Persons ORDER FirstName DESC
- SELECT * FROM Persons ORDER BY FirstName DESC
- SELECT * FROM Persons SORT BY ‘FirstName’ DESC
- SELECT * FROM Persons SORT ‘FirstName’ DESC
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
45) With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?
- INSERT (‘Olsen’) INTO Persons (LastName)
- INSERT INTO Persons (‘Olsen’) INTO LastName
- INSERT INTO Persons (LastName) VALUES (‘Olsen’)
- INSERT INTO Persons (LastName) (‘Olsen’)
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
46) How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?
- MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen
- MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
- UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
- UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
47) With SQL, how can you delete the records where the “FirstName” is “Peter” in the Persons Table?
- DELETE FirstName=’Peter’ FROM Persons
- DELETE ROW FirstName=’Peter’ FROM Person
- DELETE FROM Persons WHERE FirstName = ‘Peter’
- DELETE FROM Persons WHERE FirstName is ‘Peter’
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
48) What is the most common type of join?
- INNER
- SELF
- FULL OUTER
- EXPLICIT
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
49) Which operator is used to select values within a range?
- RANGE
- WITHIN
- BETWEEN
- IN
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
50) What is True about Indexes?
- Indexes should not be used on a smaller table
- Indexes should not be created on a column that contain more of NULL values
- Indexes should not be used on a table that is updated frequently
- All of the Above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : D[/bg_collapse]
51) how to create an Index on salary column of Customer table?
- Create Index salary_index on Customer(salary)
- Create Index on Customer(salary)
- Create Index salary_index using Customer(salary)
- Create Index salary_index on salary of customer
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
52) What does the following statement do? CREATE INDEX lower_title_idx ON books ((lower(title)));
- Modifies an index in place to be lowercase
- Creates a new index with a special operator class ‘lower’ for case insensitive comparisons.
- Creates an index for efficient case-insensitive searches on the titles column within the books table
- Nothing, it’s invalid SQL
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
53) The syntax to view the indexes of an existing postgreSQL table is :
- index database_name.table_name
- \d table_name
- \i table_name
- index table_name
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
54) Which SQL statement is used to delete records from a table?
- DELETE
- COLLAPSE
- REMOVE
- DROP
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
55) CREATE vwEmployee VIEW AS SELECT * FROM Employee WHERE ID < 100 choose the correct option
- View name must be after keyword view
- replace column name instead of *
- VIEW is an optional keyword
- there is no error in the query
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : A[/bg_collapse]
56) Views are also called as:
- Complex tables
- Simple tables
- Virtual tables
- Actual Tables
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
57) What is true about views among all the given below statements:
- View never references actual table for which it is created.
- View can’t use JOIN in it’s query.
- The performance of the view degrades if they are based on other views
- Only option to safeguard data integrity.
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]
58) Which category Delete query exits?
- DDL
- DML
- TCL
- DQL
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : B[/bg_collapse]
59) Which one is correct syntax for Where clause
- SELECT WHERE “Condition” Col1, Col2 FROM “Table” ;
- SELECT “Condition” Col1, Col2 FROM “Table” WHERE;
- SELECT Col1, Col2 FROM “Table” WHERE “condition”;
- None of the above
[bg_collapse view=”button-green” color=”#FFF” icon=”arrow” expand_text=”Show Answer” collapse_text=”Hide Answer” ]Answer : C[/bg_collapse]