Home > Database > Mysql Tutorial > Oracle的REF的读写方法

Oracle的REF的读写方法

WBOY
Release: 2016-06-07 17:09:35
Original
1254 people have browsed it

1,创建STRUCT类型 CREATE OR REPLACE TYPE STRUCT_TEST AS OBJECT (NAME VARCHAR2(50),TITLE VARCHAR2(30),NUM NUMBER(2)); 2,

1,创建STRUCT类型

CREATE OR REPLACE TYPE STRUCT_TEST AS OBJECT (NAME VARCHAR2(50),TITLE VARCHAR2(30),NUM NUMBER(2));

2,创建STRUCT类型的表并插入STRUCT类型数据

CREATE TABLE REF_TABLE OF STRUCT_TEST;

INSERT INTO REF_TABLE VALUES(’name’,'title’,1);

3,,创建测试表

CREATE TABLE TEST (

ID NUMBER(10,0) NOT NULL,

CONTENTR Ref STRUCT_TEST,

CONSTRAINT TEST_PK PRIMARY KEY(ID));

4,Ref类型的数据的插入

INSERT INTO TEST SELECT 1, REF(rt) FROM REF_TABLE rt

注意:必须采用这种方式插入数据!

5,Ref类型的数据的读取

SELECT DEREF(CONTENTR) AS r FROM TEST

SELECT DEREF(CONTENTR).NAME AS r FROM TEST

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template