Oracle Assignment
Oracle Assignment
Indexes- An index is an ordered list of content of a column or group of columns in a table. An index created on the single
column of the table is called simple index. When multiple table columns are included in the index it is called composite
index.
Syntax (Simple)
Composite Index:-
ON tablename(columnname,columnname);
Dropping Indexes:-
SYNTAX:-
Views:-
Logical data is how we want to see the current data in our database. Physical data is how this data is actually placed in our
database.
Views are masks placed upon tables. This allows the programmer to develop a method via which we can display
predetermined data to users according to our desire.
1. The DBA stores the views as a definition only. Hence there is no duplication of data.
2. Simplifies Queries.
Creation of Views:-
Syntax:-
WHERE columnname=expression_list;
Syntax:-
WHERE columnname=expression_list;
Syntax:-
Destroying a view-
Syntax:-
Sequence:-
Sequence is a set of integers 1, 2, 3, … that are generated and supported by some database systems to produce unique
values on demand.
A sequence is a user defined schema bound object that generates a sequence of numeric values.
Sequences are frequently used in many databases because many applications require each row in a table to contain a
unique value and sequences provides an easy way to generate them.
The sequence of numeric values is generated in an ascending or descending order at defined intervals and can be
configured to restart when max_value exceeds.
Creation of sequence:-
Syntax:-
CREATE SEQUENCE sequence_name
START WITH initial_value
INCREMENT BY increment_value
MINVALUE minimum value
MAXVALUE maximum value
CYCLE|NOCYCLE
[CACHE cache_size | NOCACHE]
[ORDER | NOORDER];
sequence_name: Name of the sequence.
initial_value: starting value from where the sequence starts. Initial_value should be greater than or equal
to minimum value and less than equal to maximum value.
increment_value: Value by which sequence will increment itself. Increment_value can be positive or negative.
minimum_value: Minimum value of the sequence.
maximum_value: Maximum value of the sequence.
cycle: When sequence reaches its set_limit it starts from beginning.
nocycle: An exception will be thrown if sequence exceeds its max_value.
CACHE: Specify the number of sequence values that Oracle will preallocate and keep in the memory for faster
access. The minimum of the cache size is 2. The maximum value of the cache size is based on this formula:
ORDER: Use ORDER to ensure that Oracle will generate the sequence numbers in order of request.
This option is useful if you are using Oracle Real Application Clusters. When you are using exclusive mode, then
Oracle will always generate sequence numbers in order.
NOORDER:Use NOORDER if you do not want to ensure Oracle to generate sequence numbers in order of
request. This option is the default.
Assignment:-
Client_master:
Salesorder table:
S_orderno S_orderdate Client no Dely Bill Salesman no Delay Orderstatus
type yn date
019001 12-jan-96 0001 F N 50001 20-jan- Ip
96
019002 25-jan-96 0002 P N 50002 27-jan- C
96
016865 18-feb-96 0003 F Y 500003 20-feb- F
96
019003 03-apr-96 0001 F Y 500001 07-apr- F
96
046866 20-may-96 0004 P N 500002 22- C
may-96
010008 24-may-96 0005 F N 500004 26- Ip
may-96
Sales_order_details table:
Challan_header
Challan S_order Challan Date Billed
No No
CH9001 019001 12-DEC-95 Y
CH865 046865 12-NOV-95 Y
CH3965 010008 12-OCT-95 Y
Salesman_master
Salesman_ Salesman Address City Pin State Salamt Tgt_to_get Ytd Remark
no name code Sales s
500001 Kiran A/14 Bom 400002 Maharastr 3000 100 50 Good
worli bay a
500002 Manish 65,narim Bom 400001 Maharastr 3000 200 100 Good
an bay a
500003 Ravi P-7 Bom 400032 Maharastr 3000 200 100 Good
Bandra bay a
500004 Ashish A/5 Bom 400044 Maharastr 3500 200 150 Good
Juhu bay a