随笔分类 -  PostgreSQL

摘要:当在使用PostgreSQL数据库查询数据的时候,因为查询出来的列中包含格式为json的字段 进行union报错了,该操作不支持json类型,使用union all也是同样错误 最后查阅资料得出,需要转换为jsonb才行,需要使用函数to_jsonb(你的json字段),之后,union和union 阅读全文
posted @ 2023-10-22 15:55 lqqgis 阅读(64) 评论(0) 推荐(0) 编辑
摘要:1 问题描述 在安装了PostgreSQL 13,运行psql时,出现了版本不同的警告 2 产生原因 虽然系统安装了psql(PostgreSQL) 13.3,但是psql这个脚本却引用了旧版本(9.2) 3 解决方法 替换psql脚本为新的PostgreSQL的新脚本 3.1 查找 psql 1) 阅读全文
posted @ 2021-07-29 16:15 lqqgis 阅读(733) 评论(0) 推荐(0) 编辑
摘要:1 安装环境 CentOS 7 PostgreSQL 13 PostGIS 3.1 2 安装PostgreSQL 2.1 参考官网方法安装 进入PostgreSQL官网,查看安装方法是最保险的 在官网中选择对应的版本https://www.postgresql.org/download/linux/ 阅读全文
posted @ 2021-07-29 15:14 lqqgis 阅读(6700) 评论(0) 推荐(1) 编辑
摘要:获取myTable图层的要素范围,将值以数组形式存在metaTable表的extent字段中 update metaTable set extent = (select array [st_xmin(t.box), st_ymin(t.box), st_xmax(t.box), st_ymax(t. 阅读全文
posted @ 2021-05-28 14:48 lqqgis 阅读(151) 评论(0) 推荐(0) 编辑
摘要:跨服务器间的数据库 导出/导入 -- 需要确保 远程数据库 已经存在 pg_dump -C -h localhost -p 5432 -U 本地用户名 源数据库名 | psql -h 远程host -p 5432 -U 远程用户名 远程数据库名 -- 上述代码执行后,将输入两次口令,一次是本地用户口 阅读全文
posted @ 2021-03-24 16:56 lqqgis 阅读(172) 评论(0) 推荐(0) 编辑
摘要:ArcGIS或QGIS的简单几何类型数据(如Polygon)在利用PostGIS导入到PostgreSQL中,变换成复杂几何类型(如MultiPolygon) 可以利用PostGIS的ST_GeometryN函数,将复杂几何类型转为简单几何类型 select ST_AsText(ST_Geometr 阅读全文
posted @ 2021-03-24 15:48 lqqgis 阅读(1288) 评论(0) 推荐(0) 编辑
摘要:首先,确保已经安装了与PostgreSQL版相匹配的PostGIS. (PostGIS下载地址 http://download.osgeo.org/postgis/windows/) 在想要扩展的数据库下,执行下面语句 create extension postgis; -- PostGIS的矢量数 阅读全文
posted @ 2021-03-24 15:29 lqqgis 阅读(519) 评论(0) 推荐(0) 编辑
摘要:-- 在cmd中,导出数据库,导入数据库 -- 导入 psql -h localhost -p 5432 -d 数据库名 -U postgres -f "D:\lqq\Desktop\nyc.sql" psql -h localhost -p 5432 -d 数据库名 -U postgres <D: 阅读全文
posted @ 2020-12-25 09:12 lqqgis 阅读(223) 评论(0) 推荐(0) 编辑
摘要:实现将arcgis支持的.gdb中的数据和qgis支持的.gpkg中的数据导入到Postgres数据库中。 确保Postgres安装了PostGIS组件,且已经有一个PostGIS扩展的Postgres的数据库 通过OSGeo4W安装GDAL 通过https://trac.osgeo.org/osg 阅读全文
posted @ 2020-12-18 17:54 lqqgis 阅读(2240) 评论(0) 推荐(0) 编辑
摘要:首先,在windwos环境变量中添加PostgresSQL的安装路径下bin文件的位置 此时,在cmd中使用psql命令行登录数据库需要一些参数,如psql -h localhost -U postgres -p 5432。 如果在cmd中接使用psql无需另带参数时,需要添加几个环境变量: PGH 阅读全文
posted @ 2020-12-18 10:34 lqqgis 阅读(1289) 评论(0) 推荐(0) 编辑
摘要:根据老师表(teacher),老师任课关系表(teacher2class),课程表(class),通过表连接,得到老师的任课结构表,如下: select t.id, t.name, c.title from teacher t left join teacher2class t2c on t.id 阅读全文
posted @ 2020-08-24 12:34 lqqgis 阅读(3470) 评论(0) 推荐(0) 编辑
摘要:-- 查看数据库大小 select pg_size_pretty(pg_database_size('数据库名')); --数据库中单个表的大小(不包含索引) select pg_size_pretty(pg_relation_size('表名')); --查出所有表(包含索引)并排序 SELECT 阅读全文
posted @ 2020-08-16 22:46 lqqgis 阅读(282) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示