|
Answer» A database object is any object defined in a database that is used to store or reference data. Everything we create from the create command is called a database object. It can be used to store and manipulate data. Some examples of database objects are as follows: - Table - Table is a basic storage unit with compound rows and columns. Its SYNTAX is as follows:
CREATE TABLE [schema.]table (column datatype [DEFAULT expr][, ...]);- Views - Views are a logical representation of subsets of data from one or more tables. A view is a logical table that is based on another view or a table. A view is similar to a window through which data from tables can be viewed or updated, but it does not include any data of its own. Base tables are the tables that a view is built on. In the data dictionary, the view is saved as a SELECT statement. Its syntax is as follows:
CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view [(alias[, alias]...)] AS subquery [WITH CHECK OPTION [CONSTRAINT constraint]] [WITH READ ONLY [CONSTRAINT constraint]];- Sequence - Sequences generate primary key values. A sequence is a database object that has been CREATED by a user and can be shared by several users to generate unique integers. The creation of a primary key value, which must be unique for each row, is a common use for sequences. An internal Oracle ROUTINE generates the sequence and increments (or decrements) it. Its syntax is as follows:
CREATE SEQUENCE sequence [INCREMENT BY n] [START WITH n] [{MAXVALUE n | NOMAXVALUE}] [{MINVALUE n | NOMINVALUE}] [{CYCLE | NOCYCLE}] [{CACHE n | NOCACHE}];- Indexes - Indexes are used to improve the performance of some queries on the databases. This database object is used to create an index in the database. It is a schema object that can speed up row fetching by using a pointer. Indexes can be created explicitly or automatically. If you don't have an index on the column, full crawling of the table will occur. Indexes provide direct and fast access to table rows. Its goal is to reduce disk Input and Output needs by using an indexed path to quickly locate data. The index is used and maintained automatically by the database server. Once an index is created, no direct action is required by the user. Indexes are LOGICALLY and physically independent of the table they index. This means they can be created or deleted at any time and do not AFFECT the base tables or other indexes. Its syntax is as follows:
CREATE INDEX index ON table (column[, column]...);- Synonyms - This database object is used to build database indexes. It creates a synonym to make object access easier (another name for an object). You can use synonyms to make referring to a table owned by another user easier and to shorten long object names. You must prefix the table name with the name of the user who created it, followed by a period, to refer to a table owned by another user. Creating a synonym for a table, view, sequence, procedure, or other object avoids the requirement to qualify the object name with the schema and gives you an alternate name. This approach is very handy when dealing with long object names, such as views.
In terms of syntax, the meaning of various things are as follows:- PUBLIC: creates a synonym accessible to all users
- SYNONYM: it is the name of the synonym to be created
- OBJECT: identifies the object for which the synonym is created
Its syntax is as follows: CREATE [PUBLIC] SYNONYM synonym FOR object;
|