MCQ – Basic SQL multiple-choice questions with answers for written test in software job interview in IT companies.
Q] Which statement is wrong about PRIMARY KEY constraint in SQL?
- The PRIMARY KEY uniquely identifies each record in a SQL database table
- Primary key can be made based on multiple columns
- Primary key must be made of any single columns
- Primary keys must contain UNIQUE values.
Answer:
3
Primary key of a table can be made based on single column or with combination of multiple columns.
Q] Which is/are correct statements about primary key of a table?
- Primary keys can contain NULL values
- Primary keys cannot contain NULL values.
- A table can have only one primary key with single or multiple fields
- A table can have multiple primary keys with single or multiple fields
Answer: 2 and
3
Q] In existing table, ALTER TABLE statement is used to
- Add columns
- Add constraints
- Delete columns
- Delete constrains
- All of the above
Answer:5
The ALTER TABLE statement is used to add, delete, or modify columns and constraints e.g. UNIQUE KEY, FOREIGN and NOT NULL etc. in an existing table.
Q] SQL Query to delete all rows in a table without deleting the table
[structure, attributes, and indexes]
- DELETE FROM table_name;
- DELETE TABLE table_name;
- DROP TABLE table_name;
- NONE
Answer: 1
DELETE FROM table_name; will be used to delete all rows in a table and not the table itself. To delete table itself, DROP command is used.
Q] Wrong statement about UPDATE keyword is
- If WHERE clause in missing in statement the all records will be
updated.
- Only one record can be updated at a time using WHERE clause
- Multiple records can be updated at a time using WHERE clause
- None is wrong statement
Answer: 2
If you omit the WHERE clause, ALL records will be updated.
Pages: 1 2
3 4
[Skip Breadcrumb Navigation]
Home
|
| Chapter 4
|
| Study Guide
|
| Multiple Choice
|
This activity contains 12 questions.
|
|
|
|
| A foreign key imposes a specific kind of integrity to related tables. What is the name of this integrity?
|
|
|
| Schema
|
| Referential
|
| Independence
|
| Data
|
| None of the above
|
|
|
|
|
|
|
|
|
|
|
| What are the benefits associated with database technology?
|
|
|
| Data sharing
|
| Data integration
|
| Data independence
|
| Answers #1 and #2 only
|
| Answers #1, #2, and #3
|
|
|
|
|
|
|
|
|
|
|
| Which of the following provides the low-level view of the database?
|
|
|
| Conceptual-level schema
|
| External-level schema
|
| The internal-level schema
|
| None of the above
|
|
|
|
|
|
|
|
|
|
|
| This type of key is used to link rows from one table to the rows in another table.
|
|
|
| Primary key
|
| Foreign key
|
| Encryption key
|
| Public key
|
|
|
|
|
|
|
|
|
|
|
| Which method of gathering business intelligence uses sophisticated statistical analysis and neural networks to aid in decision making?
|
|
|
| Data Warehousing
|
| Semantic data modeling
|
| Data mining
|
| None of the above.
|
|
|
|
|
|
|
|
|
|
|
| Which of the following cannot be blank [null]?
|
|
|
| Foreign key
|
| Secondary key
|
| Connecting key
|
| Primary key
|
| None of the above can be null.
|
| Two of the above cannot be null.
|
|
|
|
|
|
|
|
|
|
|
| When the same, non-key, data element is stored multiple times in table it creates an anomaly known as the:
|
|
|
| Delete Anomaly.
|
| Update Anomaly.
|
| Insert Anomaly.
|
| None of the above.
|
|
|
|
|
|
|
|
|
|
|
| Which of the following are requirements of a relational database?
|
|
|
| All nonkey [primary and foreign] attributes must describe a quality of the item identified by the primary key.
|
| Primary keys cannot be null or empty.
|
| Foreign keys [if not empty] must be a primary key in another table.
|
| All of the above.
|
| None of the above.
|
|
|
|
|
|
|
|
|
|
|
| When a non-null value for the primary key indicates that a specific object exists and can be identified by reference to its primary key value, it is referred to as
|
|
|
| the referential integrity rule.
|
| the relational database rule.
|
| the entity integrity rule.
|
| None of the above.
|
|
|
|
|
|
|
|
|
|
|
| What is [are] the component[s] of a data dictionary?
|
|
|
| Field length
|
| Field type
|
| Authorized users
|
| Data location
|
| Answers #1, #2, and #3 are correct.
|
|
|
|
|
|
|
|
|
|
|
| "Get me the date attribute of the third tuple in the sales order relation." What is being requested?
|
|
|
| The person wants the value in the date field of the third table that is related to sales order.
|
| The person wants the value in the date field in the third row of the sales order item table.
|
| The person wants the value in the date field of the third sales order that is related to the sales order item table.
|
| The person wants the value in the date field of the third record in the sales order table.
|
| None of the above.
|
|
|
|
|
|
|
|
|
|
|
| Data manipulation language is used to do which of the following?
|
|
|
| Updating the database
|
| Creating the database
|
| Querying the database
|
| All of the above
|
|
|
|
|
|
|
What is a NULL value Mcq?
Explanation: Null is used to represent the absence of a value.
What is NULL value in SQL Mcq?
Explanation: The IS NULL operator is used to testing the empty values in the table's column.
Which one of the following can have NULL?
b] Unique can have single NULL value but Primary can't have even single. Explanation: Primary key doesn't allow Null values and Unique key allows Null value, but only one Null value.
Which of the following can accept NULL values?
Primary key will not accept NULL values whereas Unique key can accept NULL values. A table can have only one primary key whereas there can be multiple unique key on a table.