Sql Flashcards
What is SQL and how is it different from languages like JavaScript?
SQL is used for performing operations on database. JavaScript is a procedural ,scripting language. SQL is a declarative language.
How do you retrieve specific columns from a database table?
select
How do you filter rows based on some specific criteria?
where
What are the benefits of formatting your SQL?
A clean and neat SQL is read faster than an inconsistently written SQL
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?
limit
How do you retrieve all columns from a database table?
*
How do you control the sort order of a result set?
order by
How do you add a row to a SQL table?
insert into in the correct order
What is a tuple?
more than one values
How do you add multiple rows to a SQL table at once?
Separate the values by commas
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?
with an update statement
Why is it important to include a where clause in your update statements?
So you can target the location where you want to update
How do you delete rows from a database table?
with a delete statement
How do you accidentally delete all rows from a table?
forgetting to put a where clause
What is a foreign key?
A foreign key is a way of combining data from two different database tables to result into one set
How do you join two SQL tables?
Use the join clause following the from clause.
The join clause using an Id
How do you temporarily rename columns or tables in a SQL statement?
Using the as keyword
What are some examples of aggregate functions?
Sum, count
What is the purpose of a group by clause?
to separate rows into groups and perform aggregate functions on those groups of rows