• Constraints

    From Dave@dboland9@protonmail.com to comp.databases.mysql on Tue Jan 12 11:21:52 2021
    From Newsgroup: comp.databases.mysql

    What is the advantage to the CONSTRAINT clause vs constraints in the table/field definition? For example:

    CREATE TABLE "Phone Number" (
    "Phone ID" INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
    "Patient ID" INTEGER NOT NULL,
    "Number" VARCHAR(10),
    "Description" VARCHAR(10),
    CONSTRAINT FK_PAT_PHN FOREIGN KEY ("Patient ID") REFERENCES "Patient" ("ID Number")
    );

    Seems to add no real functionality, but who knows.

    Dave
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Jerry Stuckle@jstucklex@attglobal.net to comp.databases.mysql on Tue Jan 12 18:07:43 2021
    From Newsgroup: comp.databases.mysql

    On 1/12/2021 11:21 AM, Dave wrote:
    What is the advantage to the CONSTRAINT clause vs constraints in the table/field definition?-a For example:

    CREATE TABLE "Phone Number" (
    "Phone ID" INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
    "Patient ID" INTEGER NOT NULL,
    "Number" VARCHAR(10),
    "Description" VARCHAR(10),
    CONSTRAINT FK_PAT_PHN FOREIGN KEY ("Patient ID") REFERENCES "Patient" ("ID Number")
    );

    Seems to add no real functionality, but who knows.

    Dave

    What storage engine are you using?
    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    jstucklex@attglobal.net
    ==================
    --- Synchronet 3.21d-Linux NewsLink 1.2