Search code examples
sqloraclesql-delete

How can I delete rows that have 2 characters or less in a particular column?


I'm cleansing a database table so that I can build a data warehouse for my coursework, however first I need to make sure that the data is of a quality.

There are a lot of name entries have only a single letter. I want to delete those rows with a single script.

Some of the name entries


Solution

  • You can get the number of chars in the column name with the function length()

    delete from tablename
    where length(trim(name)) < 2
    

    The function trim() could also be useful in this case.