SQL Select, Insert, Update, Delete, Join, Aggregates Flashcards
What is SQL and how is it different from languages like JavaScript?
Structured Query Language
Primary way of interacting with relational databases
Javascript is an imperative programming language where as SQL is a declarative programming language
Programmers describe the results they want and the programming environment comes up with its own plant or getting those results
How do you retrieve specific columns from a database table?
select “column”,
from “row”
How do you filter rows based on some specific criteria?
You use the ‘where’ clause
What are the benefits of formatting your SQL?
Consistency and readability
What are four comparison operators that can be used in a where clause?
Equals =
Less than <
Greater than >
Not equal !=
How do you limit the number of rows returned in a result set?
Using the ‘limit’ clause
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
You use the ‘order by’ clause
How do you add a row to a SQL table?
You use the ‘insert’ statement
insert into “row” (“column1”, “column2” etc..)
values (‘value1’, ‘value2’, etc..)
What is a tuple?
A list of values
How do you add multiple rows to a SQL table at once?
You separate the values in parentheses with a comma ,
insert into “row” (“column1”, “column2” etc..
values (‘value1’, ‘value2’, etc..),
‘value1’, ‘value2’, etc..)
How do you get back the row being inserted into a table without a separate select statement?
returning *
How do you update rows in a database table?
You use the update statement with a set clause
update “products”
set “price” = 100
where “productId” = 24;
Why is it important to include a where clause in your update statements?
If you do not include a where clause, it will update all price values instead of your targeted value
How do you delete rows from a database table?
delete from “row”
where “example” = ‘example’