SQL Flashcards
What is SQL and how is it different from languages like JavaScript?
It’s a declarative language you only need to tell it what to do
How do you retrieve specific columns from a database table?
by using select “column name”
How do you filter rows based on some specific criteria?
by using where + condition
What are the benefits of formatting your SQL?
To make it more readable
What are four comparison operators that can be used in a where clause?
< ,> , != , =
How do you limit the number of rows returned in a result set?
with limit (must be at the end)
How do you retrieve all columns from a database table?
with *
How do you control the sort order of a result set ?
with order by (in ascending)
else place desc for descending
How do you skip lines of code?
With offset
How do you add a row to a SQL table?
insert into “table” (“property”, …)
values (‘value’, …)
What is a tuple?
A list of values inside ( )
How do you add multiple rows to a SQL table at once?
insert into “table” (“property”, …)
values (‘value’, …),
(‘value’, …)
How do you get back the row being inserted into a table without a separate select statement?
insert into “table” (“property”, …)
values (‘value’, …),
(‘value’, …)
return *
How do you update rows in a database table?
update “table”
set “target” = value
where “condition” = comparison;
Why is it important to include a where clause in your update statements?
To pin point the specific target