CONSTRAINTS


✅ Constraints in Data Bases are used to define and Integrity Constraint, as a rule that restricts the values in a data base.

OR (in other words)

In Oracle CONSTRAINT clause allows you to restrict the date, that is entered into a column to ensure that it is valid or that is meets certain conditions.

Or 

Constraints are rules applied on table columns  to maintain accurate & valid data


Types of Constraints :--

  1. NOT NULL Constraint : Prevent NULL Values
  2. UNIQUE Constraint : No duplicate Values
  3. CHECK Constraint : Apply Condition
  4. PRIMARY KEY Constraint : Unique Identifier
  5. FOREIGN KEY Constraint : Create Relationship
  6. Default Constraint : Set default value
⚡  Why Use Constraints?  
✔️ Prevent invalid data  
✔️ Maintain consistency  
✔️ Improve data integrity  
✔️ Enforce relationships  

Scenarios for Practice Tasks  
1. Create table using PRIMARY KEY  
2. Add UNIQUE constraint on email  
3. Create FOREIGN KEY relationship  
4. Use CHECK for salary > 0  
5. Add DEFAULT city value  

⚡ Mini Challenge 🔥  
👉 Create students table with:  
- student_id → PRIMARY KEY  
- email → UNIQUE  
- age > 18 using CHECK  
- city default = 'Mumbai'

#constrains #constrains_in_oracle #oracle_constraints

No comments:

Post a Comment

Infolinks In Text Ads