SQL Flashcards
What is the one thing that SQL is trying to do well as a language?
Managing data.
Describe statements to create a table, insert into it, and then select from it.
“<img></img>”
A table can’t have that many columns
No - it can have so many, dude. Like, 2,000 just in SQLite, more elsewhere.
Which SQL statements don’t return anything?
Create, Insert, Delete, Alter, Begin
SQL statements ignore case?
Yeah. They do.
Table and column names ignore case.
Yeah, but like, there are conventions for how to make them easy to distinguish.
What are the conventions to distinguish SQL keywords from table and column names?
SQL KEYWORDS SHOUT THEIR NAME while table_and_column_names_use_lowercase_snake
SQL gives mad respect to case within strings?
Yeah. Mad respect. ‘a’ does not equal ‘A’ in a string.
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.
ERROR. ERROR. ERROR. YOU SUCK.
Why are there so many data types in various databases?
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 do you select particular columns within SQL?
“<img></img>”
“What does this return?<div><img></img><br></br></div>”
[{age: 36, name: ‘Amir’}] - It returns columns in the order requested, not the order they’re in in the DB
What is the standard equality operator in SQL?
= (not == or === )
How do you select using the where condition?
“<img></img>”
Can a where query and a select reference different columns?
“Yes,<div><img></img><br></br></div>”
What happens when multiple rows all match a WHERE condition?
They’re all returned.
What comparison operators does SQL support?
> ,
What are the two ways to SELECT using multiple columns?
AND or OR
How could you ask to return only results of a certain length?
“<img></img><div>With a custom function.</div>”
In what ways is SQLite different than production DBs?
“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>”
How does SQLite support boolean types?
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.