0% found this document useful (0 votes)
6 views

SQL 2

The document outlines key SQL concepts including the SELECT, INSERT, UPDATE, and DELETE statements, along with their syntax and purposes. It explains database normalization, its principles, and the differences between super keys and primary keys. Additionally, it covers the use of the WHERE clause for filtering data and the significance of aliases in SQL queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SQL 2

The document outlines key SQL concepts including the SELECT, INSERT, UPDATE, and DELETE statements, along with their syntax and purposes. It explains database normalization, its principles, and the differences between super keys and primary keys. Additionally, it covers the use of the WHERE clause for filtering data and the significance of aliases in SQL queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Interview Theory Questions

​ 1. What is the purpose of the SELECT statement in SQL?


The SELECT statement is used to retrieve data from one or more tables in a database.

​ 2. Explain the basic syntax of the SELECT statement.
The basic syntax is: SELECT column1, column2, ... FROM table_name WHERE
condition;

​ 3. How do you retrieve all columns from a table using the SELECT statement?
You can use an asterisk (*) to select all columns. For example: SELECT * FROM
table_name;

​ 4. What is the purpose of the INSERT statement in SQL?
The INSERT statement is used to add new records (rows) into a table.

​ 5. Explain the basic syntax of the INSERT statement.
The basic syntax is: INSERT INTO table_name (column1, column2, ...) VALUES
(value1, value2, ...);

​ 6. What is the difference between the INSERT INTO statement and the INSERT
INTO SELECT statement?
The INSERT INTO statement adds new records with explicitly specified values, while
the INSERT INTO SELECT statement inserts records by selecting data from an existing
table.

​ 7. How do you insert multiple rows into a table using a single INSERT statement?
We can use multiple sets of VALUES in the INSERT statement to insert multiple rows at
once.

8. What is database normalization, and why is it important?


Database normalization is the process of organizing data in a relational database
efficiently by reducing data redundancy and ensuring data integrity. It involves breaking
down large tables into smaller related tables and establishing relationships between
them. Normalization is essential because it:
● Reduces data duplication, which saves storage space.
● Improves data accuracy by preventing update anomalies.
● Simplifies data maintenance and ensures consistent data throughout the
database.
9. What are the key principles of normalization, and how are they achieved?
The key principles of normalization are achieved through a series of normal forms,
including:
● First Normal Form (1NF): Ensures that each column contains only atomic
(indivisible) values, and there are no repeating groups.
● Second Normal Form (2NF): Eliminates partial dependencies by removing
attributes that depend on only part of a composite primary key.
● Third Normal Form (3NF): Eliminates transitive dependencies by removing
non-prime attributes that depend on other non-prime attributes.
● Boyce-Codd Normal Form (BCNF): Ensures that for every non-trivial functional
dependency, the left-hand side is a superkey.

10.What is the difference between a super key and a primary key?


A superkey is a set of one or more columns that can be used to uniquely identify rows in
a table. A primary key is a specific type of superkey that is chosen as the main unique
identifier for a table. It is unique, non-null, and minimal (no subset of the primary key is a
unique identifier).

1. What is the purpose of the WHERE clause in SQL?


The WHERE clause is used in SQL queries to filter rows from a table based on
specified conditions. It allows us to retrieve, update, delete, or insert data selectively.

2.How can you retrieve all columns for rows that meet a specific condition using
the WHERE clause?
We can use the SELECT statement with the WHERE clause to specify the condition.
For example:
SELECT * FROM table_name WHERE condition;

3.What are some common comparison operators used in the WHERE clause?
Common comparison operators include =, != (or <>), <, >, <=, >=, BETWEEN, LIKE, IN,
and IS NULL.

4.Explain the difference between the AND and OR logical operators in the WHERE
clause.
The AND operator is used to combine multiple conditions, and all conditions must be
true for a row to be included in the result. The OR operator, on the other hand,
combines conditions, and if any of the conditions are true, the row is included in the
result.
5.What is the purpose of the UPDATE statement in SQL?
The UPDATE statement is used to modify existing records in a table based on specified
conditions. It allows us to change the values of one or more columns in selected rows.

6.What is the basic syntax of the UPDATE statement?


The basic syntax of the UPDATE statement is as follows:
UPDATE table_name SET column1 = new_value1, column2 = new_value2, ...
WHERE condition;

7.What is the purpose of the DELETE statement in SQL?


The DELETE statement is used to remove one or more rows from a table based on
specified conditions. It allows us to delete data from a table.

8.What is the basic syntax of the DELETE statement?


The basic syntax of the DELETE statement is as follows:
DELETE FROM table_name
WHERE condition;

9.How can you delete all rows from a table without specifying a condition in the
DELETE statement?
We can delete all rows from a table by omitting the WHERE clause in the DELETE
statement:
DELETE FROM table_name;

10. Explain the purpose of the FROM clause in a SQL query.

The FROM clause specifies the table or tables from which the data should be retrieved
in a SQL query. It establishes the source of the data for the SELECT statement.

11. What is the significance of the alias in the FROM clause? Provide an example.

An alias is a temporary name given to a table or a column in a query. It is used for


brevity and readability. Example: SELECT e.employee_id, e.employee_name FROM
employees

You might also like