PostgreSQL Flashcards
What is PostgreSQL?
its an open source relational database.
What is one way to see if PostgreSQL is running?
sudo service postgresql status
what is a database schema?
Collection of tables and how they are structured
What is a table?
- List of rows with the same attributes or columns
- What is a row?
- List of values that add up with the attributes in the table
- What is SQL and how is it different from languages like JavaScript?
- Structured Query Language is the primary way of interacting with relational databases. It’s a declarative language
How do you retrieve specific columns from a database table?
- Select “column” from “table”
- How do you filter rows based on some specific criteria?
- Where clause with pretiquite (where “firstName” = ‘Rob’)
- What are the benefits of formatting your SQL?
- Makes it easier to read
- What are four comparison operators that can be used in awhereclause?
- =, < , >, !=
- How do you limit the number of rows returned in a result set?
- Limit
- How do you retrieve all columns from a database table?
- Select *
- How do you control the sort order of a result set?
- Order by column name (desc)
- How do you add a row to a SQL table?* What is a tuple?
- Insert into “table” (“column”, “column”, “column”)
values (‘name’, ‘name’, name’)
What is a tuple?
- A list of values in parenthesis
- How do you add multiple rows to a SQL table at once?
- Add more than one tuple of values separated by commas.
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’),
(‘Tater Mitts’, ‘Scrub some taters!’, 6, ‘cooking’)
- How do you get back the row being inserted into a table without a separateselectstatement?
- Returning *;
- How do you update rows in a database table?
- Update “table” set “column” = ‘value’ where (pretiquite)
- Why is it important to include awhereclause in yourupdatestatements?
- it will update every row
*
* How do you delete rows from a database table?
- Delete statement
- How do you accidentally delete all rows from a table?
- Not including a where clause
When do you not put single quotes around values?
numbers and booleans do not need quotes
What is a foreign key?
Column you can use to link to another table
How do you join two SQL tables?
join “films” using (“filmId”)
How do you temporarily rename columns or tables in a SQL statement?
– as - - keyword
What are some examples of aggregate functions?
avg(“column”) or count(*)
What is the purpose of a group by clause
your aggregate is applied to those groups.