Database Reference
In-Depth Information
will be a unique identifier for that whole record/row. Moreover
Oracle creates an implicit index on that column. Index created by
Oracle on any column of a table is having the same analogy as
that of index we are having at the end of each topic. Indexes
created by Oracle serve the same purpose as the indexes at the
end of topics i.e. helps in speeding up the search process.
Example:
CREATE TABLE dept_test
(deptno NUMBER(3) CONSTRAINT pk_dept_test
PRIMARY KEY,
dname VARCHAR2(15),
loc VARCHAR2(10)
);
Once you have created this table dept_test start inserting values
in it. Remember since you have created a PRIMARY KEY
constraint on deptno, column you would not be able to insert
NULL value or anything that was already there in deptno but can
insert NULL or duplicate values in rest of the columns. Also
Oracle will create a implicit index on this primary key column
because Oracle presumes that you would be using this column a
lot in your search criteria (WHERE clause) and there are bright
chances that you may link this table with some other table using
FOREIGN KEY constraint. Once you have installed Oracle with
all the default options, Oracle Universal Installer will create a
general purpose Oracle database by default. That database will
be having dept and emp table already along with some data.
That's the reason in examples above I use the dept_test name for
table otherwise I would have used the word dept only.
Next we will create another table emp_test and link it with the
dept_test table using FOREIGN KEY constraint. Once such a
table gets created, the table having PRIMARY KEY is called the
“Parent Table” and the one having the FOREIGN KEY is called
the “Child Table”. A patent table can have as many child tables
as you like or in other words a primary key constraint column
can be linked to one or more tables using FOREIGN KEY
Search WWH ::




Custom Search