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 3488990
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:20:19+00:00 2026-05-18T11:20:19+00:00

I am trying to add a constraint (in Oracle), that restricts the user from

  • 0

I am trying to add a constraint (in Oracle), that restricts the user from creating an entries having ‘smth’, ‘smth else’ or ‘one more thing’ in a field already exist. Basically, that’s how I would write it:

ALTER TABLE sometable
ADD CONSTRAINT sometable_text_chk
CHECK (
    caption IN ( 
        SELECT caption
        FROM sometable
        WHERE text NOT IN ('smth', 'smth else', 'one more thing')
    )
)

Unfortunately, it seems to be not allowed to nest queries for this occasion. Is there perhaps a workaround.

  • 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-05-18T11:20:20+00:00Added an answer on May 18, 2026 at 11:20 am

    Basically you are trying to have some sort of a general check on the validity of the data in one table based on the data in another table (NOTE: actually probably not, waiting for the OP to clarify his question).

    Workaround is either:

    • for general case – you can do quite a lot inside triggers in terms of complex data validation (including bringing your database to a halt for even the simplest of update queries, so use with care)
    • for a bit more specific case, you are trying to accomplish some dynamic validation (a more representative example would have been useful) – you can dynamically maintain the CHECK constraint with a ‘snapshot’ of your validation (this boils down to keeping a copy of the referenced table inside the check statement, so it is quite ugly)
    • maybe you can make a foreign key check. this is not how you normally design databases, but if you look at it semantically – you claim (with your CHECK) that there is a relationship between this table and some other entity. well, if that entity is not realised as separate table, maybe it should have been? (these kinds of problems are sometimes indicators of bad design)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying (SQL Server Compact) to add primary key constraint on existing table that
I'm trying add a tab to my web page that looks like this: Using
trying to add an ExpiresDefault ExpiresByType to content on my website so that way
I'm trying to move a primary key constraint to a different column in oracle.
I'm trying to add a foreign key to an existing table, and was having
I get error 1452 when trying to do this: ALTER TABLE test.potovanja ADD CONSTRAINT
I am trying to add a check constraint which verity if after an update
I'm fairly new to Oracle and very new to APEX. I'm trying to add
i am trying to add a constraint to a datatype of char(1) i would
Trying to add an onclick handler to my tabs, and can't seem to get

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.