PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
relational database management system that often use some variation of a SQL language (Structured Query Language)
Alternatives: SQLite, mySQL, SQL server, oracle
What are some advantages of learning a relational database?
It’s widely used,
Support good guarantees about data integrity
Uses SQL language (widely used)
What is one way to see if PostgreSQL is running?
sudo service postgresql status
top
What is a database schema?
A collection of tables
Defines how the data in a relational database should be organized
What is a table?
list of rows each having the same set of attributes (columns)
What is a row?
Refers to a data in a table that has the same set of attributes/columns as the other rows
What is SQL and how is it different from languages like JavaScript?
It is a declarative language (declare things and program makes it happen from its predetermined rules
Languages like JS are imperative
How do you retrieve specific columns from a database table?
select “columnName”,
“columnName2”, etc
How do you filter rows based on some specific criteria?
Using the ‘where’ clause
e.g.
where “column” != ‘value’
What are the benefits of formatting your SQL?
It helps with 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?
‘limit’ keyword
e.g.
limit 10;
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”
default order is ascending
How do you add a row to a SQL table?
insert into “table” (…columns)
value (…values)