View, Indexe & Sequence

View

A view is a virtual table. A view contains no data itself. The tables upon which a view is based are called base tables.

Create VIEW 
CREATE VIEW view_name AS
  SELECT columns
  FROM tables
  [WHERE conditions];
Update VIEW
CREATE OR REPLACE VIEW view_name AS
  SELECT columns
  FROM table
  WHERE conditions;
Drop VIEW
DROP VIEW view_name;

Index

Indexes allow the database application to find data fast,  without reading the whole table. An index creates an entry for each value that appears in the indexed columns. Each index name must be unique in the database.

Create an Index
CREATE INDEX index_name
  ON TABLE_NAME (column1, column2, ... column_n);
Drop an Index
DROP INDEX index_name;

Sequence

You can create an autonumber field by using sequences. It can be useful to automatically generate primary key values.

Create Sequence
CREATE SEQUENCE sequence_name
  MINVALUE value
  MAXVALUE value
  START WITH value
  INCREMENT BY value
  CACHE value;
Drop Sequence
DROP SEQUENCE supplier_seq;
Advertisements