Check Constraint in Oracle | Check - oracle tutorial - sql tutorial




Oracle check constraint

Learn oracle - oracle tutorial - Oracle check constraint - oracle examples - oracle programs

What is check constraint in oracle ?

  • A check constraint allows you to specify a condition on each row in a table.
Oracle check constraints

Oracle check constraints

oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql

Syntax:

CREATE TABLE table_name
(
  column1 datatype null/not null,
  column2 datatype null/not null,

  ...

  CONSTRAINT constraint_name CHECK (column_name condition) [DISABLE]

);
click below button to copy the code. By - oracle tutorial - team

Note:

  • The check constraint defined on a table must refer to only columns in that table. It cannot refer to columns in other tables.
  • A check constraint cannot include a Subquery.
  • A check constraint can be defined in either a CREATE TABLE statement or a ALTER TABLE statement.

Example:

CREATE TABLE emp_detl
(
emp_id number(4),
emp_name varchar(20), 
emp_dbt number(4)
)
ALTER TABLE emp_detl ADD CONSTRAINT det_l CHECK (emp_dbt between 1 and 5);
click below button to copy the code. By - oracle tutorial - team

CHECK:

 oracle check create query
  1. CREATE TABLE statement is used to create a new table in oracle database and ‘emp_detl’ is the created table name.
  2. After that click on the RUN button for executing the queries
  3. After clicking the run button the table has been created successfully
 oracle check output
  1. SELECT statement is used to select all the data from created table
  2. After clicking the run button the table has been selected successfully
 oracle check alter query
  1. ALTER TABLE statement is used to modify the table in oracle database and ‘emp_detl’ is the created table name. In this statement CHECK constraint is used for specifying the condition (employee department Id must be between 1 and 5) in the emp_dbt column.
  2. After clicking the run button the table has been modified successfully
 oracle check insert query
  1. INSERT statement is used for inserting the required values in the created columns in the table
  2. After clicking the run button the check constraint provides a statement ’check constraint violated’ because the user has inserted the employee department Id more than 5. Hence the check constraint has been executed successfully.

This tutorial provides an indepth knowledge on the following items such as oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , mysql tutorial , sql tutorial for beginners , learn sql , oracle database tutorial , sql query tutorial , oracle dba tutorial , plsql tutorial , oracle tutorial pdf , oracle pl sql tutorial , oracle sql tutorial , sql tutorial point , oracle tutorial for beginners , learn oracle online free , learn oracle online , learning pl sql programming , learn sql online for free , sql learning online , dba oracle tutorial , oracle sql tutorial advanced , oracle 11g dba tutorial with examples , oracle online learning , oracle learning online , how to learn pl sql , sql coding tutorial , sql learning websites , sql basic learning

Related Searches to Check Constraint in Oracle | Check

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×