|
使用的linux为ubuntu。
1,安装PostgreSQL;(已安装跳过) 2,安装ecpg;(已安装跳过) 3,使用PostgreSQL创建一个数据库(test), 并在其中创建一个表(test(name ,age)),插入数据(haha,20); 4,创建一个文件test.pgc; 5,写入: exec sql include sqlca; int main() { exec sql connect to 'test'; exec sql begin work; exec sql update test set name = 'hehe' where age = 20; exec sql commit work; exec sql disconnect all; return 0; } 6,$ ecpg -t -I/user/include/postgresql test.pgc; 7,$ gcc -o test.exe -I/user/include/postgresql test.c -lecpg -lpq; 8,$ ./test.exe; 9,查看数据库,发现haha已经变成hehe; 10,继续学习。 |
110、esql实例
最新推荐文章于 2015-02-06 09:15:27 发布
本文介绍如何在Ubuntu系统中安装并使用PostgreSQL数据库。主要内容包括安装PostgreSQL和ecpg,通过PostgreSQL创建数据库及表,并进行数据更新操作,最后通过编程方式实现数据更新。
1619

被折叠的 条评论
为什么被折叠?



