Help Center/ GaussDB/ Developer Guide(Centralized_8.x)/ FAQ/ What wildcards are supported in GaussDB? How do I use them?
Updated on 2024-06-03 GMT+08:00

What wildcards are supported in GaussDB? How do I use them?

Answer: GaussDB supports the following three types of wildcards:
  • %: indicates any number of characters, including 0. It is used in the LIKE and NOT LIKE statements.
  • _: indicates a character, which is used in LIKE and NOT LIKE statements.
  • *: indicates any number of characters, including 0. It is used in some meta-commands.

    Examples:

    -- Use wildcards to indicate any number of characters and query the tbl_test table for the data that starts with col1 and ends with ab.
    gaussdb=#SELECT * FROM tbl_test WHERE col1 LIKE 'ab%';
    
    -- Use a wildcard to query the data of any single character string starting with a and ending with b in the col1 column of the tbl_test table.
    gaussdb=#SELECT * FROM tbl_test WHERE col1 LIKE 'a_b';
    
    -- Query all tables whose names start with tbl.
    gaussdb=#\dt tbl*