PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
It is a relational database system. Alternatives include: SQLite, MySQL
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
A database schema is a collection of tables
What is a table?
A table is a list of rows each having the same set of attributes
What is a row?
A row is a collection of related data
What is SQL and how is it different from languages like JavaScript?
It is a declarative
language like HTML
, and CSS
. Meaning: All we do is tell SQL what we want to happen and it forms the plan.
How do you retrieve specific columns from a database table?
You would retrieve it with: SELECT "columnName"
How do you filter rows based on some specific criteria?
You would use the WHERE
keyword
What are the benefits of formatting your SQL?
Pure readability
What are four comparison operators that can be used in a where
clause?
You can use:
- =
- !=
- <
- >
How do you limit the number of rows returned in a result set?
You would use the LIMIT
keyword (ex. LIMIT 5
How do you limit the number of rows returned in a result set?
You would use the LIMIT
keyword (ex. LIMIT 5
)
How do you retrieve all columns from a database table?
You would retrieve it with: SELECT *
How do you control the sort order of a result set?
One can order it with the keywords ORDER BY "columnName" (DESC/ASC)
Where if none are specified it defaults to ASC
How do you add a row to a SQL table?
~~~
INSERT INTO (“attribute1”, …“attributeN”)
VALUES (“value1”, …“valueN”);
````