0
0
SQLquery~5 mins

REPLACE function in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the REPLACE function do in SQL?
The REPLACE function searches for all occurrences of a specified substring in a string and replaces them with another substring.
Click to reveal answer
beginner
Syntax of the REPLACE function in SQL?
REPLACE(original_string, string_to_find, string_to_replace_with)
Click to reveal answer
beginner
Example: What is the result of REPLACE('apple pie', 'pie', 'tart')?
The result is 'apple tart' because 'pie' is replaced by 'tart'.
Click to reveal answer
intermediate
Can REPLACE function change multiple occurrences in a string?
Yes, REPLACE changes all occurrences of the target substring in the original string.
Click to reveal answer
beginner
What happens if the string to find is not present in the original string?
The original string is returned unchanged because there is nothing to replace.
Click to reveal answer
What does REPLACE('banana', 'a', 'o') return?
Abonono
Bbanana
Cbnn
Dbanano
Which of these is the correct syntax for REPLACE?
AREPLACE(string_to_find, original_string, replacement)
BREPLACE(original_string, string_to_find, replacement)
CREPLACE(replacement, original_string, string_to_find)
DREPLACE(original_string, replacement, string_to_find)
If REPLACE('hello world', 'x', 'y') is run, what is the output?
Aerror
Bhello yorld
Chello worly
Dhello world
Does REPLACE function modify the original data in the database?
ANo, it only returns a modified string without changing stored data
BYes, it updates the stored data automatically
CYes, but only if used with UPDATE statement
DNo, it deletes the original data
Which SQL function would you use to replace text inside a string?
ASUBSTRING
BCONCAT
CREPLACE
DTRIM
Explain how the REPLACE function works in SQL with an example.
Think about how you would change words in a sentence.
You got /4 concepts.
    What happens if the substring to replace is not found in the original string when using REPLACE?
    Consider what happens if you try to replace a word that isn't there.
    You got /3 concepts.