SQL Flashcards

1
Q

What is the one thing that SQL is trying to do well as a language?

A

Managing data.

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

Describe statements to create a table, insert into it, and then select from it.

A

“<img></img>”

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

A table can’t have that many columns

A

No - it can have so many, dude. Like, 2,000 just in SQLite, more elsewhere.

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

Which SQL statements don’t return anything?

A

Create, Insert, Delete, Alter, Begin

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

SQL statements ignore case?

A

Yeah. They do.

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

Table and column names ignore case.

A

Yeah, but like, there are conventions for how to make them easy to distinguish.

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

What are the conventions to distinguish SQL keywords from table and column names?

A

SQL KEYWORDS SHOUT THEIR NAME while table_and_column_names_use_lowercase_snake

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

SQL gives mad respect to case within strings?

A

Yeah. Mad respect. ‘a’ does not equal ‘A’ in a string.

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

What happens if you insert into a non-existant column. You know what, while we’re at it, what happens with ANY operation on a non-existant column.

A

ERROR. ERROR. ERROR. YOU SUCK.

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

Why are there so many data types in various databases?

A

Because then we can ensure that invalid data doesn’t get into the database - runtime errors are annoying but they’re far better than trying to fix a db that has allowed invalid data into the db.

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

How do you select particular columns within SQL?

A

“<img></img>”

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

“What does this return?<div><img></img><br></br></div>”

A

[{age: 36, name: ‘Amir’}] - It returns columns in the order requested, not the order they’re in in the DB

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

What is the standard equality operator in SQL?

A

= (not == or === )

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

How do you select using the where condition?

A

“<img></img>”

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

Can a where query and a select reference different columns?

A

“Yes,<div><img></img><br></br></div>”

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

What happens when multiple rows all match a WHERE condition?

A

They’re all returned.

17
Q

What comparison operators does SQL support?

A

> ,

18
Q

What are the two ways to SELECT using multiple columns?

A

AND or OR

19
Q

How could you ask to return only results of a certain length?

A

“<img></img><div>With a custom function.</div>”

20
Q

In what ways is SQLite different than production DBs?

A

“1. It doesn’t enforce column types - you can put ““test”” into an INTEGER column<div>2. Everything inserted into a TEXT column gets converted into a string - insert 7 it’s saved as ““7””</div>”

21
Q

How does SQLite support boolean types?

A

It doesn’t, really. You have to use integers with 1 as true and 0 as fasle. Most all other DBs do support boolean types though.