XMLType欄位使用方法

2021-09-01 21:28:59 字數 2594 閱讀 5356

剛才研究了一下xmltype欄位使用方法 ,現在給大家介紹一下。主要是新增、查詢、修改xmltype欄位

表結構:

建表sql:

-- create table

create table t_book (

id          varchar2(32) not null,

sys_id      varchar2(32),

type        varchar2(200),

library     varchar2(32),

title       varchar2(200),

create_user varchar2(64),

subject     varchar2(200),

description varchar2(200),

publisher   varchar2(200),

contributor varchar2(200),

create_date date,

format      varchar2(200),

inentifier  varchar2(200),

source      varchar2(200),

language    varchar2(200),

other_desc  xmltype )

tablespace dcp

pctfree 10

initrans 1

maxtrans 255

storage (

initial 64k

minextents 1

maxextents unlimited

);-- add comments to the table 

comment on table t_book

is '

數字資源結構表';

-- add comments to the columns 

comment on column t_book.library

is '

分割槽鍵';

-- create/recreate primary, unique and foreign key constraints 

alter table t_book

add constraint pk_t_book primary key (id)

using index 

tablespace dcp

pctfree 10

initrans 2

maxtrans 255

storage (

initial 64k

minextents 1

maxextents unlimited

);

新增記錄:

insert into t_book 

(id,other_desc) 

values (1 , sys.xmltype.createxml('abc

') );

insert into t_book 

(id,other_desc) 

values (2 , sys.xmltype.createxml('abcabc2') );

查詢記錄:

查詢乙個欄位中不存在的元素時,返回null值

得到id=1的value變數的值

select i.other_desc.extract('//name/a[@id=1]/@value').getstringval() as ennames, id from t_book i

rowid ennames id

1 some values 1

2 some values 2

得到a節點的值

select id,i.other_desc.getclobval(), i.other_desc.extract('//name/a/text()').getstringval() as truename from t_book i

新增節點

得到b節點id屬性的值

select i.other_desc.extract('/name/b/@id').getstringval()    as name from t_book i where i.id='1'

修改記錄:

修改乙個欄位中不存在的元素時,不會對資料有修改,但是1rows updated,所以需要提交事務。

更新id為1的記錄的xmltype欄位的a元素的id為1的value的值為some new value

update t_book set other_desc=updatexml(other_desc,'//name/a[@id=1]/@value','some new value') where id=1

更新節點裡面的資料

update t_data_892 t

set t.other_description = updatexml(t.other_description,

'//xmltype/serialnum_905s',

'12072')

where t.id='1591083'

pythonpip使用方法 pip使用方法整理

匯出專案已安裝的pip包 pip list 檢視專案中安裝的包 pip freeze requirements.txt 將專案中所用到的第三方庫輸出到requirements.txt中 pip install 版本號 pip install i 本次使用清華源進行安裝 離線安裝第三方庫 一鍵安裝整個...

使用方法 離型劑使用方法

1 使用離型劑前必須確保模具乾淨,無粉塵 蠟垢 樹脂垢 油汙等殘留物質。可以使用專用的模具潔模劑進行清洗,不可用其他液體清洗,以免清洗不乾淨或損壞模具。另外,如果您的模具是新的,在清洗乾淨後,務必要對模具進行初步處理,用離型劑在模具表面噴 刷塗5 6次,之後方可正常投入生產。2 使用離型劑時,首先要...

使用方法 卡丁車輪胎使用方法

輪胎的使用方法很重要 卡丁車輪胎是卡丁車場日常執行中的主要易損件,但是輪胎的使用方法很重要。哪些情況下會縮短輪胎的使用壽命呢?一 跑道地面粗糙 有的跑道在鋪瀝青時,或者選錯了瀝青中石子的規格,或者碾壓得不夠平整,導致路面粗糙。有的跑道使用現成的水泥地,但表面粗糙或不平整。有的室內跑道,為了提高輪胎的...