1.如何创建对象类型
语法:
CREATE TYPE type_name as OBJECT (
column_1 type1,
column_2 type2,
...
);
e:
CREATE TYPE OB_HUMAN AS OBJECT(
NAME VARCHAR2(20),
SEX VARCHAR2(1)
)
2.使用对象类型创建一个表(此表就称之为对象类型表),使用时,跟普通表一样(增删改查).
语法:
CREATE TABLE table_name OF object_type;
e:
CREATE TABLE TB_STUDENTS OF OB_HUMAN;
INSERT:
INSERT INTO TB_STUDENTS VALUES ('xling','M');
INSERT INTO TB_STUDENTS VALUES (OB_HUMAN('yangyang','F'));
QUERY:
SELECT * FROM TB_STUDENTS
DELETE:
DELETE FROM TB_STUDENTS WHERE SEX='F'