SQL Databases Flashcards

(100 cards)

1
Q

What does SQL stand for?

A

Structured Query Language

SQL is a standard database language developed by IBM in the 1970s.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the main purpose of SQL?

A

To access and manipulate data in databases

SQL can create, update, delete, and retrieve data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a database?

A

A structured form of data storage in a computer

It includes schemas, tables, queries, views, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Does SQL support programming language features?

A

False

SQL is a command language and does not include conditional statements like loops.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between CHAR and VARCHAR2 data types?

A

CHAR is fixed length; VARCHAR2 is variable length

Example: CHAR(5) stores 5 characters; VARCHAR2(5) stores up to 5 characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Data Definition Language (DDL)?

A

A subset of SQL that defines data structures

Includes commands like CREATE, DROP, and ALTER.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Data Manipulation Language (DML)?

A

A subset of SQL used to manipulate data

Functions include inserting, deleting, retrieving, and updating data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a view in SQL?

A

A virtual table created from one or more tables

Views can display all or specific rows based on conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a foreign key?

A

A field that uniquely identifies each row in another table

It creates a link between two tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are table and field in SQL?

A

A table is a combination of rows and columns; a field is a single piece of information

Rows are records, and columns are fields.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a primary key?

A

The most important candidate key in a table

There can only be one primary key per table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a DEFAULT constraint?

A

Used to fill a column with default values

The default value is added when no other value is provided.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is normalization?

A

A process to analyze relation schemas to minimize redundancy and anomalies

It involves decomposing schemas that do not meet desirable properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is denormalization?

A

A technique to add redundant data to avoid costly joins

It is applied after normalization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a query?

A

A request to retrieve data from the database

Queries can vary in efficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a subquery?

A

A query within another query

It is typically embedded in the WHERE clause.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the different operators available in SQL?

A

Arithmetic, Logical, and Comparison Operators

These operators allow for various data manipulations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a constraint in SQL?

A

Rules applied to data types in a table

Constraints limit the type of data stored in specific columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is data integrity?

A

The correctness and consistency of data in a database

Data must satisfy certain procedures to maintain integrity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is Auto Increment?

A

A feature that automatically generates a unique identifier for new records

It simplifies the process of assigning primary keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is MySQL collation?

A

A set of rules for comparing characters in a character set

Each character set can have multiple collations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are user-defined functions?

A

Functions created to provide functionality not available in SQL

They can be used in various SQL statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are the types of user-defined functions?

A
  1. Scalar User-Defined Function
  2. Inline Table-Value User-Defined Function
  3. Multi-statement Table-Value User-Defined Function

Each type serves different purposes in SQL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a stored procedure?

A

A group of SQL statements that perform DML operations

It accepts parameters and may return a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are aggregate and scalar functions?
Aggregate functions return a single value from multiple values; scalar functions return a single value based on user input ## Footnote Each category has multiple sub-functions.
26
What is an ALIAS command?
A temporary name given to a table or column for a specific query ## Footnote It enhances readability but does not change the original name.
27
What are the Set Operations in SQL?
Set Union, Set Intersection ## Footnote These operations eliminate duplicate tuples and apply to union-compatible relations.
28
What are aliases in SQL?
Aliases are useful when table or column names are big or not very readable. They are preferred when there is more than one table involved in a query.
29
What are the set operations available in SQL?
Set operations available in SQL are: * Set Union * Set Intersection * Set Difference
30
What does the UNION operation do?
The UNION operation includes all the tuples which are present in either of the relations and automatically eliminates duplicates.
31
What is the difference between UNION and UNION ALL?
UNION eliminates duplicates, while UNION ALL retains all duplicates.
32
What does the INTERSECT operation do?
The INTERSECT operation includes the tuples which are present in both of the relations and automatically eliminates duplicates.
33
What is the EXCEPT operation used for?
The EXCEPT operation includes tuples that are present in one relation but not in another relation, automatically eliminating duplicates.
34
What is T-SQL?
T-SQL stands for Transact Structured Query Language, an extension of SQL by Microsoft used to interact with relational databases.
35
What are the types of T-SQL functions?
Types of T-SQL functions are: * Aggregate functions * Ranking functions * Rowset functions * Scalar functions
36
What does ETL stand for in SQL?
ETL stands for Extract, Transform, Load, a process in Data Warehousing.
37
How can you copy tables in SQL?
You can copy tables using the command: CREATE TABLE Clone_1 LIKE Original_table;
38
What is SQL injection?
SQL injection is a technique used to exploit user data through web page inputs by injecting SQL commands.
39
Can we disable a trigger in SQL?
Yes, we can disable a trigger using the ALTER TRIGGER statement with the DISABLE option.
40
What is the difference between SQL and PL/SQL?
Common differences include: * SQL is a query execution language, while PL/SQL is a complete programming language. * SQL is data-oriented; PL/SQL is procedural.
41
What does the BETWEEN operator do in SQL?
The BETWEEN operator fetches rows based on a range of values.
42
What does the IN operator do in SQL?
The IN operator checks for values contained in specific sets.
43
How do you find employee names starting with 'A' in SQL?
Use the query: SELECT * FROM Employees WHERE EmpName LIKE 'A%';
44
What is the difference between primary key and unique constraints?
A primary key cannot have NULL values, while unique constraints can. There can be only one primary key but multiple unique constraints.
45
What is a join in SQL?
An SQL Join statement combines data from two or more tables based on a common field.
46
What are the types of joins in SQL?
Types of joins include: * INNER JOIN * LEFT JOIN * RIGHT JOIN * FULL JOIN
47
What is a database index?
A database index is a data structure that improves the speed of data retrieval operations at the cost of additional writes and storage.
48
What is the ON DELETE CASCADE constraint?
An 'ON DELETE CASCADE' constraint deletes rows from the child table automatically when rows from the parent table are deleted.
49
What does the WITH clause do in SQL?
The WITH clause defines a temporary relationship whose definition is available only to the query in which it occurs.
50
What are the attributes of indexes?
Attributes of indexes include: * Access Types * Access Time * Insertion Time * Deletion Time * Space Overhead
51
What is a cursor in SQL?
A cursor is a temporary memory allocated by the database server for performing DML operations.
52
What are the types of relationships in SQL?
Types of relationships include: * One-to-One * One-to-Many * Many-to-One * Self-Referencing
53
What is a trigger in SQL?
A trigger is a statement executed automatically when there is any modification to the database.
54
What is the difference between SQL DELETE and SQL TRUNCATE commands?
DELETE removes rows one at a time and logs each deletion, while TRUNCATE deallocates data pages and logs only the page deallocations.
55
What is the difference between Clustered and Non-Clustered Index?
Clustered index reorders table records to match the index, while non-clustered index does not.
56
What is a Live Lock?
A Live Lock occurs when processes repeatedly interact without doing any useful work.
57
What is CASE WHEN in SQL?
The CASE statement handles if/then logic in SQL for query filtering and optimization.
58
What is a deadlock in the context of processes?
A situation where all processes are in the waiting state.
59
What is the purpose of the CASE statement in SQL?
It handles if/then logic.
60
What is the syntax for the CASE statement in SQL?
CASE case_value WHEN when_value THEN statement_list [WHEN when_value THEN statement_list] … [ELSE statement_list] END CASE
61
Name the three types of case manipulation functions available in SQL.
* LOWER * UPPER * INITCAP
62
What is a global variable in SQL?
A variable defined outside of functions with global scope.
63
What is a local variable in SQL?
A variable defined within functions with local scope.
64
What function is used to remove spaces at the end of a string in SQL?
Trim function.
65
What is the difference between TRUNCATE and DROP statements in SQL?
* DROP removes the table definition and contents * TRUNCATE deletes all rows but retains the table structure
66
What operator is used in SQL queries for pattern matching?
LIKE operator.
67
What does the ORDER BY statement do in SQL?
Sorts fetched data in ascending or descending order.
68
Explain the HAVING statement in SQL.
Specifies a condition for a group or aggregate function after grouping.
69
What do the AND and OR operators do in SQL?
Filter data based on multiple conditions.
70
Define the BETWEEN statement in SQL.
Tests if an expression is within a range of values (inclusive).
71
What does the COMMIT command do in SQL?
Permanently saves changes made by the current transaction.
72
What does the ROLLBACK command do in SQL?
Undoes changes made by the current transaction.
73
What are ACID properties in database transactions?
Atomicity, Consistency, Isolation, Durability.
74
Are NULL values the same as zero or a blank space?
No, NULL means data might not be provided.
75
What are group functions in SQL?
Functions that group values of multiple rows to form a single value.
76
Name some group functions in SQL.
* Count() * Sum() * Avg() * Min() * Max()
77
What is the MERGE statement used for in SQL?
Combines INSERT, UPDATE, and DELETE operations.
78
How can you fetch common records from two tables?
Using JOIN.
79
What are the advantages of PL/SQL functions?
* Improves performance * Enhances readability * Promotes reusability * Ensures security
80
What SQL query returns the current date?
CURRENT_DATE.
81
What are nested triggers in SQL?
Triggers that contain data modification logic within themselves.
82
How can you find the available constraint information in a table?
Using the data dictionary.
83
How can you avoid getting duplicate entries in a query without using DISTINCT?
* Remove duplicates using row numbers * Self-join * Group by
84
What is the difference between NVL and NVL2 functions?
* NVL converts NULL to an actual value * NVL2 returns expr2 if expr1 is not NULL, otherwise returns expr3
85
What is the difference between COALESCE() and ISNULL()?
* COALESCE returns the first non-NULL expression * ISNULL replaces NULL values
86
What operator is used in SQL for appending two strings?
Concentration operator (||).
87
What is SQL?
SQL stands for Structured Query Language and is a standard database language used for accessing and manipulating data in databases.
88
Who developed SQL?
SQL was developed by IBM Computer Scientists in the 1970s.
89
What are the key features of the GATE 2025 preparation program?
The program includes: * 60 Subject-Wise Mock Tests * 4500+ PYQs and practice questions * 20 Full-Length Mock Tests * Personalized insights with student rankings * Expert-designed tests by industry pros and GATE CS toppers.
90
What additional features are offered in the GATE 2025 program?
Additional features include: * All India Mock Test * Live GATE CSE Mentorship Classes * Live Doubt Solving Sessions.
91
Fill in the blank: SQL is easy to learn, there are _______ to learn SQL.
no prerequisites
92
List some basic SQL concepts covered in the tutorial.
* SQL queries * SQL join * SQL injection * SQL insert * Creating tables in SQL.
93
What topics are included in advanced SQL?
* SQL Indexes * SQL Miscellaneous Topics * SQL Interview Questions.
94
True or False: SQL includes data constraints.
True
95
What is the primary purpose of SQL?
To access and manipulate data in databases.
96
What are the types of programming languages mentioned?
* Python * Java * C++ * PHP * GoLang * SQL * R Language.
97
What is the significance of the GATE 2025 exam?
It is designed to help candidates secure a top rank in their academic and professional pursuits.
98
List some subjects covered in the competitive programming section.
* Data Structures * Algorithms * Basic DSA Problems.
99
Fill in the blank: The company address is located in _______.
Noida, Uttar Pradesh
100
What types of courses are available under Data Science?
* Data Science With Python * Data Science For Beginner * Machine Learning * ML Maths * Data Visualisation * Pandas * NumPy * NLP * Deep Learning.