中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

4.2.6 Database Systems: String Operations

1. The most commonly used operation on strings is pattern matching using the operator like.

2. String matching operators % (any substring) and (underscore, matching any character).
E.g., "_%" matches any string with at least 3 characters.

3. Patterns are case sensitive, e.g., "Jim" does not match "jim".

4. Use the keyword escape to define the escape character.

E.g., like "ab%tely\%\\" escape "n" matches all the strings beginning with "ab" followed by a sequence ofcharacters and then "tely" and then "%\".Backslash overrides the special meaning of these symbols.

5. We can use not like for string mismatching.

6. Example. Find all customers whose street includes the substring "Main".

select cname
from customer
where street like "%Main%"

7. SQL also permits a variety of functions on character strings, such as concatenating (using "k"), extracting substrings, nding the length of strings, converting between upper case and lower case, and so on.

Database System Structure: