postgresQL Flashcards
What is postgreSQL and what are some alternative relational databases?
open source relational database management system
What are some advantages of learning a relational database?
most apps use data
easier to work with data that is related
What is one way to see if postgreSQL is running?
top command in CLI
sudo service postgresql status command in CLI
What is a database schema?
a collection of tables
What is a table?
a table is a list of rows each having the same set of attributes(aka columns)
What is a row?
each row is a single record of data in the table
what is SQL and how is it different from languages like JS?
sql is a language used to interact with relational databases
sql is declarative language rather than imperative like JS
you describe the result you want rather than what and how to do it like with JS
How do you retrieve specific columns from a database table?
use the “select” keyword and the string version of the columns in double quotes you wish to see separated by commas
How do you filter rows based on some specific criteria?
use the “where” statement
“columnName” operator (‘dataValue’)
What are the benefits of formatting your SQL?
readability
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 clause followed by num value
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
order by “columnName” desc/asc
How do you add a row to a SQL table?
insert into “table” (“columnName”, “columnName)
values (‘firstName’, ‘lastName’)
returning *;