PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
A relational database; MySQL, SQL Server, Oracle
What is a database schema?
All of the tables in a database
What is a table?
Specifies each attribute the rows should have
What is a row?
A single object in the table
What is SQL and how is it different from languages like JavaScript?
SQL is a language used to retrieve, create, and manipulate data in a relational database. It differs from JavaScript in that is a declarative programming language, so the programmer describes the results they want and the programming environment comes up with its own plan for getting those results.
How do you retrieve specific columns from a database table?
With the SELECT keyword, column names enclosed with double quotes and separated by commas.
How do you filter rows based on some specific criteria?
With a WHERE keyword, followed by a column you wanted to filter by enclosed in double quotes, then a comparison operator, then the value to compare against.
What are the benefits of formatting your SQL?
To enhance readability for other developers.
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?
With the LIMIT keyword, followed by an integer.
How do you retrieve all columns from a database table?
By replacing the list of column names with an asterisk.
How do you control the sort order of a result set?
With an ORDER BY keyword, followed by the column you want to sort by enclosed in double quotes, and then an optional DESC keyword to reverse sort order.
How do you add a row to a SQL table?
With an insert statement;
Insert into keywords followed by table name enclosed in double quotes, followed by an attribute list enclosed in parentheses. Then the values keyword followed any tuples.
What is a tuple?
A tuple is a set of values for one row.
How do you add multiple rows to a SQL table at once?
By adding multiple tuples after the values keyword in an insert statement, with commas in between.