Which SQL command is used to create a table?
Database Concepts and SQL — Important Questions
SUMMARY: This chapter introduces students to fundamental database concepts and the use of SQL for managing and manipulating databases.
KEY TOPICS: relational databases, SQL commands, data types, primary key, foreign key, normalization, DDL, DML, constraints, joins
Which SQL clause is used to filter records?
Check answerHide answer
Which SQL function returns the number of rows?
Check answerHide answer
Which SQL clause is used with GROUP BY for filtering grouped data?
Check answerHide answer
Which join returns matching rows from both tables only?
Check answerHide answer
Differentiate between WHERE and HAVING clauses in SQL.
Differentiate between DELETE and DROP commands in SQL.
Write a SQL query to display name and salary of all employees from the table employee.
Explain the use of GROUP BY clause with one example.
Write a SQL query to find the average salary of employees department-wise.
Write SQL queries to: (a) create a table employee (b) insert 3 rows (c) display employees with salary > 30000 (d) update salary of one employee (e) delete one employee.
Discuss any five SQL aggregate functions with examples.
Differentiate between INNER JOIN LEFT JOIN and RIGHT JOIN with one example each.
Discuss SQL constraints — PRIMARY KEY FOREIGN KEY UNIQUE NOT NULL CHECK DEFAULT — with examples.
Write SQL queries to: (a) sort employees by salary descending (b) display employees of HR department (c) count employees per department (d) display top 3 highest-paid employees.
Differentiate between primary key and foreign key in tabular form.
Assertion (A): SELECT is a DQL command.
Reason (R): It retrieves data from one or more tables.
Show explanationHide explanation
Assertion (A): GROUP BY groups rows with same value in a column.
Reason (R): It is often used with aggregate functions.
Show explanationHide explanation
Assertion (A): COUNT(*) returns the total number of rows.
Reason (R): COUNT(column) ignores NULL values in that column.
Show explanationHide explanation
Assertion (A): DELETE removes rows from a table.
Reason (R): DROP removes the entire table including its structure.
Show explanationHide explanation
Assertion (A): The LIKE operator is used for pattern matching.
Reason (R): Wildcard % matches any sequence of characters.
Show explanationHide explanation
Statement 1: DDL commands include CREATE ALTER and DROP.
Statement 2: They modify the structure of the database.
Show answerHide answer
Statement 1: DML commands include INSERT UPDATE and DELETE.
Statement 2: They modify the data within tables.
Show answerHide answer
Statement 1: WHERE filters rows before grouping.
Statement 2: HAVING filters groups after aggregation.
Show answerHide answer
Statement 1: JOIN combines rows from two or more tables.
Statement 2: The join is based on a related column.
Show answerHide answer
Statement 1: A NULL value represents missing data.
Statement 2: It is different from zero or empty string.
Show answerHide answer
-
Which command retrieves data?ASELECTBFROMCWHEREDCOUNT
-
Which clause groups rows for aggregation?AWHEREBHAVINGCGROUP BYDORDER BY
-
Write SQL queries for all four manager requirements.
Show answersHide answers
Match each database key with its definition.
| Key | Definition |
|---|---|
| Primary | ? |
| Candidate | ? |
| Alternate | ? |
| Foreign | ? |
| Composite | ? |
For sample employee table compute each SQL query result.
| emp_id | name | dept | salary |
|---|---|---|---|
| 1 | Anil | IT | 50000 |
| 2 | Bobby | HR | 40000 |
| 3 | Chitra | HR | 35000 |
| 4 | Geeta | IT | 60000 |
| 5 | Hari | Sales | 40000 |
Match each SQL clause with its purpose.
| Clause | Purpose |
|---|---|
| SELECT | ? |
| WHERE | ? |
| GROUP BY | ? |
| HAVING | ? |
| ORDER BY | ? |
| LIMIT | ? |
Match each SQL command type with its commands.
| Type | Commands |
|---|---|
| DDL | ? |
| DML | ? |
| DQL | ? |
| DCL | ? |
| TCL | ? |
Study the SQL JOIN Venn diagrams and answer:
-
Which JOIN returns only matching rows from both tables?AINNER JOINBLEFT JOINCFULL JOINDCROSS JOIN
-
Which JOIN returns all rows from the left table plus matches from the right?AINNERBLEFTCRIGHTDFULL
-
Differentiate between INNER LEFT and FULL JOINs with examples.
Show answersHide answers
Study the sample employee table and answer:
-
The maximum salary in the table is:A35000B40000C60000D225000
-
Which employees are from IT department?AAnilBGeetaCBoth Anil and GeetaDHari
-
Write SQL queries to find: (a) employees with salary > 40000 (b) count of employees per department.
Show answersHide answers
Study the SQL aggregate function results and answer:
-
Which function returns the total number of rows?ACOUNT(*)BSUM(salary)CAVG(salary)DMAX(salary)
-
Which function returns the average?ASUMBAVGCMINDMAX
-
Discuss any five SQL aggregate functions with one example each.
Show answersHide answers
Make a full Informatics Practices paper on Database Concepts and SQL.
Pick the question mix, set the marks, hit generate. You get a ready-to-print paper with an answer key.
Generate your paper — free