Lesson 6 Flashcards

String manipulation (10 cards)

1
Q

String data can be notoriously difficult and annoying to work with because:

A
  • It can be a pain to get strings in the correct format you want
  • String data can have a lot of variation and mistakes, which can be hard to account for
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

There are SO many string manipulation functions you can use to modify and manipulate strings— honestly too many to learn and remember!

Do NOT stress about learning them all because:

A

You can easily Google or ChatGPT the syntax as you have different goals and use cases come up.

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

How can you change a column name?

For example, from the orders table:

  • Pull the order_id column
  • Pull the order_id column and rename it to nickname_order_id
A

AS

  • Alias
  • You can rename your columns at any time, as anything you want
SELECT
    order_id,
    order_id AS nickname_order_id
FROM
    orders
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

len()

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

concat()

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

replace()

A
  • replace() is a great function to sort through strings and replace a certain part with something else
  • Can replace with an empty string ''
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

trim()

A
  • chop off part of a string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ltrim()

A

left trim

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

rtrim()

A

right trim

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

split_part()

A
  • A delimiter is a separator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly