SQL Flashcards

1
Q

✅Delete (2) vs (2) Truncate

A

Delete
1 - slower
2 - you can rollback data Truncate

Truncate
1 - faster
2 - rollback not possible

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

✅Explain each type of Join

A

(INNER) JOIN: Returns records that have matching values in both tables

LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table

RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table

FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table

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

✅ char vs varchar2

A

char
1 - fixed length,

eg char(10) stores 10 characters, no more no less

varchar2
1 flexible length
eg varchar2(10) stores between 1 and 10 characters

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

✅ Constrains

A

Not null

unique

primary key

foreing key

check

default

index

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

✅ Data Integrity

A

Refers to the accuracy and consistency of data

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

✅ Subsets of SQL

A

DDL - Data Definition Language

DML - Data Manipulation Language

DCL - Data Control Language

TCL - Transaction Control Language

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

Triggers (6)?

A

Before insert
After insert

Before update
After update

Before delete
After delete

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

✅ Cross Join

A

Produces cartesian product of two tables

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

✅ List some Aggregate Functions (6)

A

1 - AVG
2 - COUNT
3- SUM
4 - MAX
5 - MIN

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

Different between Scalar Functions and Aggregate Functions

A

Aggregate Functions are based on the columns

Scalar Functions are based on the input value

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

✅ Merge statement

A

Syncrhonize two tables by inserting, updating or deleting rwos based on differences found

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

✅ What is a SQL Clause?

A

Conditions to limit the result, like WHERE or HAVING

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

✅ List the ways in which Dyamic SQL can be executed?

A

1- sp_executesql

2- EXEC

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

✅ How to select unieque records from a table?

A

DISTINCT

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

✅ What function would you use to fetch first the 5 characters of a string?

A

SUBSTRING

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

✅ Different set operators (3)

A

1- UNION

2- INTERSECT

3- MINUS

17
Q

✅ What is a View?

A

It’s a virtual table based on the result set of an SQL statement

18
Q

✅ Clustered index (3) vs (3) non-clustered index

A

Clustered
1 - One per table
2 - Faster
3- Physical Order

Non-clustered
1 - Many per table
2 - Slower
3- Logical order

19
Q

Como auto-incrementar IDs?

A

Identity

20
Q

✅ Authentication Modes

A

Central repository of information

21
Q

✅ How to add a number on each row?

A

ROW_NUMBER() OVER(ORDER BY
name
ASC)

AS row

22
Q

⚠️ How to improve query performance?

A
23
Q

⚠️ What is SQL Profiler?

A
24
Q
A