PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
Postgres is an open source relational database. MySQL, Microsoft SQL, and Oracle
What are some advantages of learning a relational database?
Web developers will use a database
What is one way to see if PostgreSQL is running?
run sudo service postgreql start in one terminal and run top in another.
What is a database schema?
A collect of tables that your data conforms to.
What is a table?
A list of rows with the same attributes
What is a row?
A single record in the database.
What is SQL and how is it different from languages like JavaScript?
The language used to interact with relational databases. It is declarative.
How do you retrieve specific columns from a database table?
select “blank” from “blank”
How do you filter rows based on some specific criteria?
where clause
What are the benefits of formatting your SQL?
Makes it easier to find certain rows or columns
What are four comparison operators that can be used in a where clause?
equal, less than, greater than, not equal
How do you limit the number of rows returned in a result set?
Limit clause followed by number
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
Order by price - (auto ascending)
order by price “price” desc
How do you add a row to a SQL table?
insert clause
into ‘table name’
What is a tuple?
A list of values
How do you add multiple rows to a SQL table at once?
Each set of value in parentheses separated by commas.
How do you get back the row being inserted into a table without a separate select statement?
returning clause
How do you update rows in a database table?
update clause ‘table name’
Why is it important to include a where clause in your update statements?
to target a specific row
How do you delete rows from a database table?
delete clause
How do you accidentally delete all rows from a table?
delete from ‘table name’
no where clause
What is a foreign key?
A column in one table that refers to values in another table.
How do you join two SQL tables?
join clause “tableName” using (“columnName”)