SQL Flashcards
What is SQL and how is it different from languages like JavaScript?
SQL is way of interacting with relational databases and is different from JavaScript because it is a declarative programming languages. You also don’t really tell the computers what to do.
How do you retrieve specific columns from a database table?
using select “column name or attributes”
How do you filter rows based on some specific criteria?
you use where clause “column name” = the ‘row name’
What are the benefits of formatting your SQL?
It makes your code easier to read and decipher
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 operator
How do you control the sort order of a result set?
order by “column name” - by default it is ascending order and can make it descending by desc operator
How do you retrieve all columns from a database table?
select *
How do you add a row to a SQL table?
using insert keyword with what columns and values you want to insert
What is a tuple?
list of values
How do you add multiple rows to a SQL table at once?
you specify more than one tuple of values, separated by commas
How do you get back the row being inserted into a table without a separate select statement?
using returning *
How do you update rows in a database table?
use update statement with “file name” and set clause
Why is it important to include a where clause in your update statement?
Without the where clause, set value will be updated to all rows
How do you delete rows from a database table?
Use delete statement with where clause