久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Oracle與PostgreSQL數據寫入的方法是什么

140次閱讀
沒有評論

共計 2680 個字符,預計需要花費 7 分鐘才能閱讀完成。

這篇文章主要介紹“Oracle 與 PostgreSQL 數據寫入的方法是什么”,在日常操作中,相信很多人在 Oracle 與 PostgreSQL 數據寫入的方法是什么問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Oracle 與 PostgreSQL 數據寫入的方法是什么”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學習吧!

在特殊字符(不可見字符,如 ASCII 0、控制字符、非法字符等)上,Oracle 非常寬松,基本上可以寫入任何數據,包括不符合編碼規則的數據。而 PostgreSQL 則不然,必須符合該字符集的編碼,比如在 UTF8 字符集下,輸入的字符編碼比如符合 UTF8 編碼。

Oracle
字符集為 GBK,創建數據表,插入特殊字符(0x00),沒有問題

TEST-orcl@DESKTOP-V430TU3 drop table t_0x00 purge;
Table dropped.
TEST-orcl@DESKTOP-V430TU3 create table t_0x00(id int,c1 varchar2(200),c2 blob);
Table created.
TEST-orcl@DESKTOP-V430TU3 insert into t_0x00 values(1,chr(0),null);
1 row created.
TEST-orcl@DESKTOP-V430TU3 insert into t_0x00 values(2, c1 ||chr(0),null);
1 row created.
TEST-orcl@DESKTOP-V430TU3 insert into t_0x00 values(3,chr(0)|| c1 ,null);
1 row created.
TEST-orcl@DESKTOP-V430TU3 insert into t_0x00 values(4, c1 ||chr(0)|| c1 ,null);
1 row created.
TEST-orcl@DESKTOP-V430TU3 insert into t_0x00 values(5, c1 ||chr(0)|| c1 ,to_blob(HEXTORAW( 550055)));
1 row created.
TEST-orcl@DESKTOP-V430TU3 
TEST-orcl@DESKTOP-V430TU3 select * from t_0x00 where c1 like  % ||chr(0)|| % 
 ID C1 C2
---------- -------------------- --------------------
 1
 2 c1
 3 c1
 4 c1 c1
 5 c1 c1 550055
TEST-orcl@DESKTOP-V430TU3

PostgreSQL
字符集為 UTF8,創建數據表,插入特殊字符(0x00),無法插入

[local:/data/run/pg12]:5120 pg12@testdb=# \encoding
[local:/data/run/pg12]:5120 pg12@testdb=# drop table t_0x00;
insert into t_0x00 values(4, c1 ||E \x00 || c1 ,null);
insert into t_0x00 values(5, c1 ||E \x00 || c1 , \x550055 ::bytea);DROP TABLE
[local:/data/run/pg12]:5120 pg12@testdb=# create table t_0x00(id int,c1 varchar(200),c2 bytea);
CREATE TABLE
[local:/data/run/pg12]:5120 pg12@testdb=# 
[local:/data/run/pg12]:5120 pg12@testdb=# insert into t_0x00 values(1,E \x00 ,null);
ERROR: invalid byte sequence for encoding  UTF8 : 0x00
[local:/data/run/pg12]:5120 pg12@testdb=# insert into t_0x00 values(1,chr(0),null);
ERROR: null character not permitted
[local:/data/run/pg12]:5120 pg12@testdb=# insert into t_0x00 values(2,null,bytea  \x00 
INSERT 0 1
[local:/data/run/pg12]:5120 pg12@testdb=# insert into t_0x00 values(3,E \x00 || c1 ,null);
ERROR: invalid byte sequence for encoding  UTF8 : 0x00
[local:/data/run/pg12]:5120 pg12@testdb=# insert into t_0x00 values(4, c1 ||E \x00 || c1 ,null);
ERROR: invalid byte sequence for encoding  UTF8 : 0x00
[local:/data/run/pg12]:5120 pg12@testdb=# insert into t_0x00 values(5, c1 ||E \x00 || c1 , \x550055 ::bytea);
ERROR: invalid byte sequence for encoding  UTF8 : 0x00
[local:/data/run/pg12]:5120 pg12@testdb=# select * from t_0x00 where c1 like  % ||chr(0)|| % 
ERROR: null character not permitted
[local:/data/run/pg12]:5120 pg12@testdb=#

在 Oracle – PG 的遷移過程中,這些特殊字符是需要考慮的。

到此,關于“Oracle 與 PostgreSQL 數據寫入的方法是什么”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注丸趣 TV 網站,丸趣 TV 小編會繼續努力為大家帶來更多實用的文章!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-26發表,共計2680字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 温泉县| 红原县| 抚顺市| 石门县| 册亨县| 新宁县| 大理市| 浏阳市| 顺昌县| 定州市| 靖边县| 松滋市| 灯塔市| 阳江市| 应用必备| 横山县| 临猗县| 绥宁县| 通城县| 通道| 双峰县| 黎城县| 肇东市| 鱼台县| 赤水市| 施秉县| 乡城县| 巴青县| 咸阳市| 双桥区| 宜良县| 固始县| 治县。| 东乌珠穆沁旗| 浪卡子县| 区。| 常德市| 灵石县| 布拖县| 浑源县| 巴南区|