From the course: Oracle Database 12c: Basic SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Check constraints

Check constraints - Oracle Database Tutorial

From the course: Oracle Database 12c: Basic SQL

Start my 1-month free trial

Check constraints

- [Instructor] Check constraints in SQL allows us to create tables and specify that the values inserted to one or more of the columns in the table need to meet a very specific, user-supplied rule, so that we can control which values will be accepted when we insert data, and which values will be rejected. So for example, we can create a table and specify that, for a name column that exists in this table, all values inserted need to be uppercase. So, lowercase values will be rejected. Let's see this example in action. Create table, demo_table_new, this is the name of the table, and specify two columns, id number precision four, and name of the varchar2 data type, precision 50. So far, so good. Now we specify a check constraint. We do that by typing constraint, followed by the constraint name, which can be any name you choose, check_uppercase_name, in my case, and then specify the constraint type, check, in our case. Check signifies that this constraint will check incoming values when…

Contents