Skip to Main Content

Write Great SQL Office Hours

Free tips and training every month! Subscribe for reminders and more from Office Hours. FAQ

Header container

July 18, 2023

13:00 UTC   Start Times Around the World

Subscribe to be notified of changes to sessions and give us feedback!

Having trouble watching the video on this page? Open the video in your browser.

Description

How to modify constraints in Oracle Database
From time to time, you may need to change a constraint. For example, adding values to a CHECK constraint IN list or changing the columns in a unique constraint.

Sadly there's no syntax to make these changes. You need to drop and recreate the constraint with the new criteria.

Watch the recording to learn how to make these changes while the application is online & keep your data safe!

Highlights include:

- 00:30 The problem with changing constraints
- 03:00 Reasons for changing constraints
- 12:20 Changing CHECK constraints
- 20:00 Demo of changing CHECK constraints
- 30:10 Adding/removing NOT NULL constraints
- 33:00 Changing columns in a UNIQUE constraints
- 35:30 Demo changing NOT NULL & UNIQUE
- 39:00 Changing PRIMARY KEY
- 43:30 Changing FOREIGN KEY
- 47:35 Adding a surrogate key to a table
- 53:30 Demo changing PRIMARY & FOREIGN keys
- 57:30 Summary

Read the blog post https://bit.ly/change-constraint-blog
Get the scripts https://bit.ly/SQL-ATOH-change-constraints-script

Learn SQL for free https://devgym.oracle.com/pls/apex/dg/class/databases-for-developers-foundations .html

Your Experts

  • #SELECTION#
    Chris Saxon

    Chris Saxon   

    Chris Saxon is an Oracle Developer Advocate and quizmaster on Dev Gym. His job is to help you get the best out of the Oracle Database and have fun with SQL! He's also part of the answer team on Ask TOM and creates YouTube videos at The Magic of SQL channel.
    #MISC#
    #ACTIONS#