PostgresQL/SQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
It is a relational database. Alternative relational databases include MySQL, SQL Server by Microsoft and Oracle.
What are some advantages of learning a relational database?
Most widely used type of database. You can store related data easily
What is one way to see if PostgreSQL is running?
Run ‘sudo service postgresql status’ in the terminal. Can also check in your terminal by running the command ‘top’
What is a database schema?
A collection of tables. A description of how the database should be structured
What is a table?
A list of rows with the same set of attributes
What is a row?
A set of related data describing one item
What is SQL and how is it different from languages like JavaScript?
The primary way of interacting with relational databases. It is a declarative programming language where programmers describe the results they want rather than tell it exactly what to do and how to do it.
How do you retrieve specific columns from a database table?
Using the select statement and a comma-separated list of column names, each wrapped in a pair of quotes, followed by the from clause specifying which table to grab the data from and ending with a semicolon.
How do you filter rows based on some specific criteria?
Using the where clause. It needs to evaluate as true or false
What are the benefits of formatting your SQL?
It gives it a consistent style and it’s easier to read.
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?
Using the limit clause followed by the number you want to limit it by
How do you retrieve all columns from a database table?
By using *
How do you control the sort order of a result set?
Using the order by clause. It is defaulted to ascending, so if you want it descending, you must include ‘desc’ at the end.
How do you add a row to a SQL table?
Using the insert ‘keyword into statement’ followed by the name of the table in quotes and a list of columns individually in quotes being inserted wrapped in parentheses. The values clause and the values being inserted are also wrapped in parentheses in the same order as the columns.