Csyr2 Advanced Database Lab
Csyr2 Advanced Database Lab
Csyr2 Advanced Database Lab
ADT are the data types created by the programmer having subtypes.
There are several reasons why ADT's are useful within an object
database
V arrays have a defined lower value 0 and maximum could be any valid
number.
Collector such as varying array allows repetition of only those column
Each row within the object table has OIDan object identifier
value.
COMMIT;
END;
/
Data Access
street varchar2(30),
city varchar2(20),
state varchar2(10),
pincode varchar2(10) );
/
Cont…
CREATE OR REPLACE TYPE customer AS OBJECT
(code number(5),
name varchar2(30),
contact_no varchar2(12),
addr address,
member procedure display );
/
DECLARE
residence address;
BEGIN
residence := address('103A', 'M.G.Road', 'Jaipur',
'Rajasthan','201301');
dbms_output.put_line('House No: '|| residence.house_no);
dbms_output.put_line('Street: '|| residence.street);
dbms_output.put_line('City: '|| residence.city);
dbms_output.put_line('State: '|| residence.state);
dbms_output.put_line('Pincode: '|| residence.pincode);
END;
/
Using Map method
Purpose
Use the ALTER TYPE statement to add or drop member attributes or
methods. You can change the existing properties
(FINAL or INSTANTIABLE) of an object type, and you can modify the
scalar attributes of the type.
You can also use this statement to recompile the specification or body of
the type or to change the specification of an object type by adding new
object member subprogram specifications.
Prerequisites
The object type must be in your own schema and you must
have CREATE TYPE or CREATE ANY TYPE system privilege, or you
must have ALTER ANYTYPE system privileges.
Syntax
ELEMENT TYPE datatype
This clause lets you increase the precision, size, or
length of a scalar datatype of a varray or nested table.
This clause is not valid for collections of object types.
For a collection of NUMBER, you can increase the
precision or scale.
For a collection of RAW, you can increase the
maximum size.
For a collection of VARCHAR2 or NVARCHAR2,
you can increase the maximum length.
Increasing the Length of a Collection Type
partition by range(attribute)
ALTER :Change the table definition with the ALTER TABLE statement.
DELETE :Remove rows from the table with the DELETE statement.
Note: You must grant the SELECT privilege on the table along with the
DELETE privilege.
statement.
INSERT: Add new rows to the table with the INSERT statement.
Con…
Note: You must grant the SELECT privilege on the table along