Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to add foreign key in mysql 8.0 while creating table

[CONSTRAINT [symbol]] FOREIGN KEY
    [index_name] (col_name, ...)
    REFERENCES tbl_name (col_name,...)
    [ON DELETE reference_option]
    [ON UPDATE reference_option]

reference_option:
    RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
    
    CREATE TABLE parent (
    id INT NOT NULL,
    PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE child (
    id INT,
    parent_id INT,
    INDEX par_ind (parent_id),
    FOREIGN KEY (parent_id)
        REFERENCES parent(id)
        ON DELETE CASCADE
) ENGINE=INNODB;
Comment

PREVIOUS NEXT
Code Example
Sql :: sql server convert string list integers list 
Sql :: sqlalchemy query return only n results 
Sql :: oracle tablespace owners 
Sql :: how to delete a database record after a certain time 
Sql :: restart sequence table mysql 
Sql :: select nth row in mysql 
Sql :: FILENAME /usr/bin/mysql does not exists. Make sure correct path is set in /etc/dump admin/settings.conf. 
Sql :: apikey in pl sql 
Sql :: how to add mysql to path on termin after installation 
Sql :: sqdqsd 
Sql :: How To Execute SQL Select Statements 
Sql :: mysql table information 
Sql :: http://challenge01.root-me.org:58036/wsasd 
Sql :: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL 
Sql :: how to escape single quotes in SQL 
Sql :: cahnge column name apex oracle 
Sql :: sql query tags 
Sql :: Downloading snowsql for Linux 
Sql :: hex string sql becomes int64 
Sql :: transaction and commit trong sql server 
Sql :: select between dates opstgres 
Sql :: postgresql exploit 
Sql :: apex call duration 
Sql :: mysql primary vs unique 
Sql :: big query get distinct array of objects 
Sql :: Use Join On DataTables | Join Two Tables With ssp.class.php (Select & Search) 
Sql :: employee name starting with in sql 
Sql :: ring close the connection to the database using the odbc_disconnect() 
Sql :: optimize sql query 
Sql :: while in plsql 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =