About 128,000 results
Open links in new tab
  1. sql - How to Alter Constraint - Stack Overflow

    You can not alter constraints ever but you can drop them and then recreate. Have look on this. ALTER TABLE your_table DROP CONSTRAINT ACTIVEPROG_FKEY1; and then recreate it with ON DELETE CASCADE like this. ALTER TABLE your_table add CONSTRAINT ACTIVEPROG_FKEY1 FOREIGN KEY(ActiveProgCode) REFERENCES PROGRAM(ActiveProgCode) ON DELETE CASCADE;

  2. MySQL Constraints - W3Schools

    Column level constraints apply to a column, and table level constraints apply to the whole table. The following constraints are commonly used in SQL: PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table.

  3. mysql - Foreign key constraints: When to use ON UPDATE and ON DELETE

    Let's look at the ON UPDATE clause: ON UPDATE RESTRICT: the default: if you try to update a company_id in table COMPANY the engine will reject the operation if one USER at least links on this company. ON UPDATE NO ACTION: same as RESTRICT.

  4. Can you replace or update a SQL constraint? - Stack Overflow

    May 3, 2012 · The correct answer is on stackoverflow.com/questions/13244889/how-to-alter-constraint -- No, you cannot alter constraints ever. Drop the constraint, and then add the replacement constraint. You can't update a constraint in SQL Server at least.

  5. MySQL :: MySQL 9.3 Reference Manual :: 15.1.22.5 FOREIGN KEY Constraints

    SET NULL: Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL.Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported. If you specify a SET NULL action, make sure that you have not declared the columns in the child table as NOT NULL.

  6. How to change a foreign key constraint in MySQL

    May 18, 2020 · This is how you change a foreign key constraint in MySQL. Tagged with mysql, database, tutorial, sql.

  7. Alter Constraints in SQL - Baeldung

    Feb 27, 2025 · In this tutorial, we’ll discuss constraint alterations in the following relational databases: MySQL (version 8), PostgreSQL (version 17), and SQLServer 2022. We’ll use our University Simple schema to define example queries.

  8. Referential Constraints and Foreign Keys in MySQL

    Aug 17, 2017 · Foreign keys and referential constraints allow you to set relationships between tables and modify database engine’s actions. See how to use it in MySQL.

  9. 1.6.3 How MySQL Deals with Constraints

    Jul 1, 2011 · MySQL enables you to work both with transactional tables that permit rollback and with nontransactional tables that do not. Because of this, constraint handling is a bit different in MySQL than in other DBMSs.

  10. How To Update Constraint In Mysql - Restackio

    Apr 9, 2025 · Learn the steps to effectively update constraints in MySQL for better database management and integrity. To update primary key constraints in MySQL, you need to follow a structured approach that ensures data integrity and maintains relationships between tables.