Stavros Kasapi
Stavros Kasapi

Reputation: 5

SQL constraint for a variable to start with a letter followd by numbers

I'm a beginner on oracle apex and im trying to implement a constraint that only allows variables in a column that start with a certain letter ('P') and are followed by numeric digits. Any help?

Upvotes: 0

Views: 1116

Answers (1)

Mureinik
Mureinik

Reputation: 311228

You could use the regexp_like operator:

ALTER TABLE mytable
ADD CONSTRAINT mytable_field_check
CHECK (REGEXP_LIKE (myfiled, 'P[0-9]*'))

Upvotes: 1

Related Questions