sql Flashcards
What is SQL and how is it different from languages like JavaScript?
it is a declaritive language. So instead of telling the language to “find” something. You can tell it what to find, and it will do it itself
How do you retrieve specific columns from a database table?
you use:
select (name of column)
How do you filter rows based on some specific criteria?
you can use the where
clause.
you can get a subset of all rows in a table depending on the criteria
where “category” = ‘cleaning’
What are the benefits of formatting your SQL?
The readability of your data
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?
using the limit
command
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
by using order by
with the column selected.
it will be ascending by default, but can be descending if stated otherwise
How do you add a row to a SQL table?
using the insert
clause with the designating table
What is a tuple?
a tuple is a group of values that is encased in a parenthsis
How do you add multiple rows to a SQL table at once?
within the values
clause. you would add X-amount of parenthesis seperated by commas. each new tuple
will be a new row.
How do you get back the row being inserted into a table without a separate select statement?
use the returning
clause followed with a *. This will return the row that you have created. If you want specific values, you would replace the * with the list column items
How do you update rows in a database table?
you use the update
clause followed with the update
and where
Why is it important to include a where clause in your update statements?
IT IS IMPORTANT TO USE the WHERE
clause to make sure that you are not updating EVERYTHING
How do you delete rows from a database table?
use the delete from
clause folowered by a where clause