Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:57:51+00:00 2026-06-02T14:57:51+00:00

Forgive me, if this problem is solved in another ticket on SO… I’ve been

  • 0

Forgive me, if this problem is solved in another ticket on SO… I’ve been searching, but can’t seem to find quite the right solution…

I am creating a table. Column ‘Creditor’ is numeric all the way, EXCEPT that the very last char may be a dash.

This means that examples like ‘1234-‘, ‘92846293’ and so on, are valid, and that ‘12354-53’, ‘12345K’ are invalid.
The string length is not fixed (except it’s a varchar(50)).

I don’t know how to create the check constraint.

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:57:52+00:00Added an answer on June 2, 2026 at 2:57 pm

    You did not state your DBMS. For PostgreSQL this would be:

    alter table foo 
      add constraint check_creditor check (creditor ~ '^([0-9]+)\-?$');
    

    For Oracle this would be:

    alter table foo 
       add constraint check_creditor check (regexp_like(creditor, '^([0-9]+)\-?$'))
    

    If your DBMS supports regular expressions, you will need to use the syntax for your DBMS to check this. The regular expression itself '^([0-9]+)\-$' will most probably be the same though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Forgive me if this is a dumb beginners problem, but I really don't get
Forgive me if this has been asked before, but I assure you I've scoured
I am new to PHP so please forgive if this question or problem seem
I am quite new to IOS development, so forgive me if this problem turns
I can't seem to find a question on SO about my particular problem, so
Forgive me if this has already been asked (and feel free to provide a
Forgive me if this is a tried question, but I'm having a little difficulty
Forgive me for this seemingly obvious question, but my searches have not revealed the
I've been having a heckuva time with this problem, and there seems to be
C++ is not my language so forgive this simple problem. I'm losing precision in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.