Foreign Key Oracle | Foreign Key - oracle tutorial - sql tutorial
Learn oracle - oracle tutorial - Oracle foreign key - oracle examples - oracle programs
What is oracle foreign key ?
- A foreign key means that values in one table must also appear in another table.
- The referenced table is called the parent table while the table with the foreign key is called the child table. The foreign key in the child table will generally reference a primary key in the parent table.
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql
Syntax:
Example:
FOREIGN KEY: (PARENT TABLE)
- CREATE TABLE statement is used to create a new table in oracle database and ‘wikitechy3’ is the created table name.
- In this statement PRIMARY KEY constraint is used and applied for tech_Id column.
- After that click on the RUN button for executing the queries
- After clicking the run button the table has been created successfully
- INSERT statement is used for inserting the required values in the created columns in the table
- After that click on the RUN button for executing the queries
- After clicking the run button the table has been inserted successfully
- SELECT statement is used to select all the data from created table
- After that click on the RUN button for executing the queries
- After clicking the run button the table has been selected successfully.
FOREIGN KEY: (CHILD TABLE)
- CREATE TABLE statement is used to create a new table in oracle database and ‘wikitechy1’ is the created table name.
- In this statement FOREIGN KEY constraint is used and applied for tech_Id column.
- After that click on the RUN button for executing the queries
- After clicking the run button the table has been created with the foreign key successfully
- INSERT statement is used for inserting the required values in the created columns in the table
- After that click on the RUN button for executing the queries
- After clicking the run button the table has been inserted successfully
- SELECT statement is used to select all the data from created table.
- After that click on the RUN button for executing the queries
- After clicking the run button the table has been selected successfully