PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS). Some other relational databases are MySQL or Oracle.
What are some advantages of learning a relational database?
It works well with storing related data, and almost all of them use the same language so it isn’t hard to switch from one relational database to another.
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
a collection of tables that correspond to each other
What is a table?
a collection of data that is related with each other
What is a row?
collection of values that correspond to the attributes of that table
What is SQL and how is it different from languages like JavaScript?
SQL is a powerful way of retrieving, creating, and manipulating data in a relational database. It is a declarative language where as JavaScript is a imperative language
How do you retrieve specific columns from a database table?
By including them in the select statement
How do you filter rows based on some specific criteria?
using the where statement followed by the row name and then the criteria
What are the benefits of formatting your SQL?
easier readability
What are four comparison operators that can be used in a where clause?
=, , !=
How do you retrieve all columns from a database table?
by including an asterisk in the select statement
How do you control the sort order of a result set?
using an order by statement
How do you limit the number of rows returned in a result set?
using a limit statement
How do you add a row to a SQL table?
by using insert into, the table name, then the column names you want to edit. Then on the following line use a values clause and add the value in order to the listed column names above
What is a tuple?
a list of values
How do you add multiple rows to a SQL table at once?
list multiple tuples
How do you get back the row being inserted into a table without a separate select statement?
by using returning followed by an asterisk
How do you update rows in a database table?
Using the update clause followed by the table name, then use the set clause and set a value or values to one or more column names. then display exactly which row you want to change by using the where clause.
Why is it important to include a where clause in your update statements?
So it doesn’t effect the whole column of values
How do you delete rows from a database table?
By using the delete from clause followed by the table name. using the where clause after will let you specify what item or items you want to delete.
How do you accidentally delete all rows from a table?
when you only include the delete from line followed by a table name
What is a foreign key?
A key or id that relates to another tables contents
How do you join two SQL tables?
using the from and join clause
How do you temporarily rename columns or tables in a SQL statement?
use the as keyword
What is the purpose of a group by clause?
to apply the aggregate functions to a clump of rows