PostgreSQL Flashcards

1
Q

What is PostgreSQL?

A

its an open source relational database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a database schema?

A

Collection of tables and how they are structured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a table?

A
  • List of rows with the same attributes or columns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • What is a row?
A
  • List of values that add up with the attributes in the table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • What is SQL and how is it different from languages like JavaScript?
A
  • Structured Query Language is the primary way of interacting with relational databases. It’s a declarative language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you retrieve specific columns from a database table?

A
  • Select “column” from “table”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  • How do you filter rows based on some specific criteria?
A
  • Where clause with pretiquite (where “firstName” = ‘Rob’)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  • What are the benefits of formatting your SQL?
A
  • Makes it easier to read
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  • What are four comparison operators that can be used in awhereclause?
A
  • =, < , >, !=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  • How do you limit the number of rows returned in a result set?
A
  • Limit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  • How do you retrieve all columns from a database table?
A
  • Select *
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  • How do you control the sort order of a result set?
A
  • Order by column name (desc)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  • How do you add a row to a SQL table?* What is a tuple?
A
  • Insert into “table” (“column”, “column”, “column”)

values (‘name’, ‘name’, name’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a tuple?

A
  • A list of values in parenthesis
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  • How do you add multiple rows to a SQL table at once?
A
  • Add more than one tuple of values separated by commas.
    values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’),
    (‘Tater Mitts’, ‘Scrub some taters!’, 6, ‘cooking’)
17
Q
  • How do you get back the row being inserted into a table without a separateselectstatement?
A
  • Returning *;
18
Q
  • How do you update rows in a database table?
A
  • Update “table” set “column” = ‘value’ where (pretiquite)
19
Q
  • Why is it important to include awhereclause in yourupdatestatements?
A
  • it will update every row
20
Q

*

* How do you delete rows from a database table?

A
  • Delete statement
21
Q
  • How do you accidentally delete all rows from a table?
A
  • Not including a where clause
22
Q

When do you not put single quotes around values?

A

numbers and booleans do not need quotes

23
Q

What is a foreign key?

A

Column you can use to link to another table

24
Q

How do you join two SQL tables?

A

join “films” using (“filmId”)

25
Q

How do you temporarily rename columns or tables in a SQL statement?

A

– as - - keyword

26
Q

What are some examples of aggregate functions?

A

avg(“column”) or count(*)

27
Q

What is the purpose of a group by clause

A

your aggregate is applied to those groups.