SQL Flashcards
What is SQL and how is it different from languages like JavaScript?
SQL is declarative - programmer describes results they want and the computer figures it out
JavaScript is imperative - programmer writes the machine instructions
How do you retrieve specific columns from a database table?
Select “column”,
“column”
From “row”;
How do you filter rows based on some specific criteria?
where “column“ = ‘text value’
What are the benefits of formatting your SQL?
To lessen complexity
What are four comparison operators that can be used in a where clause?
Less than, greater than, equal, not equal
How do you limit the number of rows returned in a result set?
limit #
How do you retrieve all columns from a database table?
universal *
How do you control the sort order of a result set?
Order by “column” (desc) or (asc)
How do you add a row to a SQL table?
insert into “table” (“column”, “column”)
values (‘value’, value’);
What is a tuple?
a list of values in SQL
How do you add multiple rows to a SQL table at once?
comma separated list of tuples.
How do you get back the row being inserted into a table without a separate select statement?
returning * or comma-separated column names;
How do you update rows in a database table?
update “table”
set “column” = value
where “target” = target value;
Why is it important to include a where clause in your update statements?
to target a specific row, others all rows would be updated.
How do you delete rows from a database table?
delete
from “table”
where “target” = “target value”