fieldtore.blogg.se

Sqlitestudio foreign key
Sqlitestudio foreign key













sqlitestudio foreign key

Restrict: if reference rows is updated from parent table then related rows from child table is restricted.

sqlitestudio foreign key sqlitestudio foreign key

Set Null: When we delete reference rows from parent table then related rows from child table are null.

#Sqlitestudio foreign key update

  • Cascade: When we make some changes that means update or delete records in parent table then corresponding rows from child table automatically update or delete.
  • We can make foreign keys at the time of table creation or we can utilize an adjust order to add foreign keys into the predetermined table.Īt the point when we use reference_option in foreign key, the reference_option acknowledges the following five unique qualities as follows. Rules and Regulations for foreign keyīasically foreign keys are used as referential integrity constraints in SQLite and it is work between parent table and child table. SQLite supports the different actions as follows.Īs per our requirement we can use any action. Mainly there are two constraints as follows.
  • SQLite foreign key constraint or we can say action as follows.
  • When we try to insert the above records at that time it shows an error message because common_id 4 does not exist in the dist_unit table.
  • Now try to insert another record as follows.Ĭode: Insert into distributor (dist_name, common_id) values ("LG", 4) Now insert some records into the dist_unit table by using insert into statement as follows.
  • We successfully created a booth table as shown in the below screenshot as follows.
  • Here common_id id foreign key reference from dist_units.
  • In the above example we use a create table statement to create a new table name as distributor with attributes such as dist_id with integer data type and also have a primary key constraint, dist_name with text data type and common_id with integer data type as shown in above statement.
  • Now create a distributor table with different attributes by using the following statement.Ĭode: create table distributor (dist_id integer primary key, dist_name text not null, common_id integer not null, foreign key (common_id) references dist_units (common_id)) Now first create two tables to implement foreign keys as follows.įirst create a dist_unit with different attributes by using the following statement as follows.Ĭode: create table dist_unit (common_id integer primary key, unit_name text not null)















    Sqlitestudio foreign key