SQL Flashcards

1
Q

What’s the difference between CREATE VIEW and CREATE OR REPLACE VIEW?

A

The latter drops a view with the name specified in the statement if it already exists, and creates it again, saving you from running into errors, and saving you time by not needing to drop the view before

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

Which are the 4 types of JOINs?

A

Left, right, inner, and outer

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

What’s a self join?

A

A join that links a table to itself

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

Which are the 3 statements to join 2 tables?

A

ON, WHERE, and USING

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

Is cross join the same as self join?

A

No

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

When to use indexes?

A

Whenever you want to improve performance

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

Which are the 4 primitives data types?

A

Integer, string, boolean, and float

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

What’s the difference between CHAR and VARCHAR?

A

The former only accepts fixed-length values, whereas the latter accepts values regardless of their length

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

Which are the 3 main types of relationships?

A

One-to-one, one-to-many, and many-to-many

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

Can a primary key be nullable?

A

No

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

Can a boolean column be a primary key?

A

No

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

Which are the constraints you can set on a column?

A

Not null, unique, primary key, foreign key, check, and default

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

What does the rollback statement mean within a transaction block?

A

If an error occurs within the block, it will rollback the data to its previous status, discarding any changes that might have occurred during its execution

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

How do you guarantee referencial data integrity?

A

Foreign keys and constraints

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

What would you use a stored procedure for?

A

To improve performance for a complex query, as it would compile once, and run based on an execution plan that is created the first time the procedure is ran

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