Postgresql 提供了外鍵表的功能,sqlite_fdw唯一的遺憾是只能select,希望github上能夠盡快更新吧!
成都創(chuàng)新互聯(lián)公司是一家專業(yè)提供水磨溝企業(yè)網(wǎng)站建設(shè),專注與成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、H5建站、小程序制作等業(yè)務(wù)。10年已為水磨溝眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。
下面我把sqlite_fdw 如何使用介紹下!
1、下載sqlite_fdw 軟件包:
git clone https://github.com/gleu/sqlite_fdw 或者下載 .ZIP壓縮文件
make
[postgres@mxl sqlite_fdw]$ make
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -fpic -I. -I./ -I/usr/local/pgsql/include/server -I/usr/local/pgsql/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/sqlite_fdw.o src/sqlite_fdw.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -fpic -shared -o sqlite_fdw.so src/sqlite_fdw.o -L/usr/local/pgsql/lib -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags -lsqlite3
make install
[root@mxl sqlite_fdw]# make install
/bin/mkdir -p '/usr/local/pgsql/lib'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/doc/extension'
/usr/bin/install -c -m 755 sqlite_fdw.so '/usr/local/pgsql/lib/sqlite_fdw.so'
/usr/bin/install -c -m 644 sqlite_fdw.control '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 sql/sqlite_fdw--0.0.1.sql '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 doc/sqlite_fdw.md '/usr/local/pgsql/share/doc/extension/'
2、在數(shù)據(jù)庫(kù)引用sqlite_fdw
postgres=# CREATE EXTENSION sqlite_fdw;
CREATE EXTENSION
postgres=# \dx ;
List of installed extensions
Name | Version | Schema | Description
--------------------+---------+------------+-----------------------------------------------------------
pg_stat_statements | 1.2 | public | track execution statistics of all SQL statements executed
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
sqlite_fdw | 0.0.1 | public | SQLite Foreign Data Wrapper
uuid-ossp | 1.0 | public | generate universally unique identifiers (UUIDs)
(4 rows)
3、創(chuàng)建一個(gè)fdw的server
CREATE SERVER sqlite_server FOREIGN DATA WRAPPER sqlite_fdw OPTIONS (database '/tmp/localdb.sqlite');
4、創(chuàng)建外鍵表
CREATE FOREIGN TABLE fdwuserrole(userid integer,roleid ingeter) SERVER sqlite_server OPTIONS (table 'userrole');
5、查看外鍵表server
postgres=# \des
List of foreign servers
Name | Owner | Foreign-data wrapper
---------------+----------+----------------------
sqlite_server | postgres | sqlite_fdw
(1 row)
6、刪除外鍵表
drop FOREIGN table fdwuserrole;
問(wèn)題:1
src/sqlite_fdw.c:37:21: error: sqlite3.h: No such file or directory
make 的時(shí)候提示解析不了sqlite頭文件
rpm -Uvh http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/atomic-release-1.0-21.el6.art.noarch.rpm
yum update
yum sqlite-devel install -y
問(wèn)題:2
安裝sqlite_fdw的時(shí)候需要使用postgres 的pg_config 所以需要把postgres 的環(huán)境變量在root 添加一下
分享文章:sqlite_fdw使用
轉(zhuǎn)載來(lái)于:http://www.rwnh.cn/article22/jcjpcc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、營(yíng)銷型網(wǎng)站建設(shè)、企業(yè)網(wǎng)站制作、網(wǎng)站改版、網(wǎng)站排名、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)