3

I have a column NAME
It must contain only characters and not numbers
How do I use CHECK condition:

CHECK(NAME NOT LIKE '%[0-9]%')

or any other method...

edit: Oracle database is used.

Pop Stack
  • 926
  • 4
  • 19
  • 27
  • 1
    LIKE (at least in the SQL Standard) does not support regular expressions. –  Jan 06 '12 at 10:46

2 Answers2

4

You didn't state your DBMS so I'm assuming PostgreSQL

CHECK(name ~ '^[^0-9]*$')
3

Double negative Should be standard (not MySQL though) because it uses LIKE:

CHECK(NAME NOT LIKE '%[^a-zA-Z]%')
Community
  • 1
  • 1
gbn
  • 422,506
  • 82
  • 585
  • 676