Database Objects

First, Let’s understand what is DataBase Object ?

A database object is a data structure used to either store or reference data. The most common object that people interact with is the table. Other objects are indexes, stored procedures, sequences, views and much more.

 

Most of the major database engines offer the same set of major database object types:

  • Tables

  • Indexes

  • Sequences

  • Views

  • Synonyms

 

Table in SQL

Oracle stores information in the form of tables. For eg. you can have a table named as Employee in which you can store information about the employees of an organization in the form of columns which could be the Employee Name, Salary, Department etc.

In the terms of a relational database, one can call a table as a Department and the columns as it attributes.

 

Index in SQL

Indexing is a concept of the listing of keywords accompanied by the location of information of the subject. Indexes are used to speed up the processing, especially searching.

 

View in SQL

A view is a way of hiding the logic that created the joined table just display the data.

Example –

SQL > Create or Replace view AB
select A.emp_id, B.department  from A, B where A.dept_id = B.id;

You can query it as select emp_id, department from AB.

 

Sequence in SQL

Tables usually have a primary key which uniquely identifies a row in a table. A sequence is a unique number generator which can be assigned to the primary keys of the tables.

Example –

SQL> CREATE SEQUENCE sequence_dcc
MINVALUE 1000
MAXVALUE 999999999
START WITH 1001
INCREMENT BY 1
CACHE 10;

 

Synonyms in SQL

A synonym is a name assigned to a table or view that may be used refer to it thereafter. If you have an access to another users table, you may create a synonym for it and refer to it by the synonym alone, without entering the user’s name as a qualifier.
Using synonyms is a good way to implement location transparency.

 

0 Comment

Leave a Reply