postgresql

CREATE EXTENSION postgis fails,

早过忘川 提交于 2020-12-31 04:45:32
问题 I am on Ubuntu 18.04 with the psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1) Running temba=# create extension postgis; fails with the following error ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory I ran find /usr -name postgis.control only to find out postgis.control is inside a folder named 12 instead of 10 laptop@xyz-x:~$ find /usr -name postgis.control /usr/share/postgresql/12/extension/postgis.control Edit 1

CREATE EXTENSION postgis fails,

不羁的心 提交于 2020-12-31 04:44:28
问题 I am on Ubuntu 18.04 with the psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1) Running temba=# create extension postgis; fails with the following error ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory I ran find /usr -name postgis.control only to find out postgis.control is inside a folder named 12 instead of 10 laptop@xyz-x:~$ find /usr -name postgis.control /usr/share/postgresql/12/extension/postgis.control Edit 1

Returning ranked search results using gin index with sqlalchemy

旧街凉风 提交于 2020-12-30 11:54:35
问题 I have a GIN index set up for full text search. I would like to get a list of records that match a search query, ordered by rank (how well the record matched the search query). For the result, I only need the record and its columns, I do not need the actual rank value that was used for ordering. I have the following query, which runs fine and returns the expected results from my postgresql db. SELECT *, ts_rank('{0.1,0.1,0.1,0.1}', users.textsearchable_index_col, to_tsquery('smit:* | ji:*'))

Python+SQL无敌组合,值得你Pick!

老子叫甜甜 提交于 2020-12-30 11:39:00
T U SHARE 金融与技术学习兴趣小组 翻译整理 | Little monster 本期编辑 | Little monster 译者简介:北京第二外国语学院国际商务专业研一在读,目前在学习Python编程和量化投资相关知识。 作者: Nicholas Samuel × DataCamp SQL 是结构化查询语言 Structured Query Language 的简称,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统。 在正式讲解代码之前,先来科普一下数据库相关的知识。 数据库是以一定方式储存在一起、能与多个用户共享、具有尽可能小的冗余度、与应用程序彼此独立的数据集合。数据库系统具有如下特点: ① 数据结构化 实现整体数据的结构化,这里所说的“整体”结构化,是指在数据库中的数据不再仅针对某个应用,而是面向全组织;不仅数据内部是结构化,而且整体式结构化,数据之间有联系。 ② 数据共享性高 多个用户可以同时存取数据库中的数据,甚至可以同时存取数据库中的同一个数据。 ③ 数据冗余度低 减少重复数据的存储,节约存储空间。 ④ 数据独立性高 用户的应用程序与数据库的物理存储结构和逻辑结构是相互独立的。 数据库可以分为两类, 关系型数据库 和 非关系型数据库NoSQL(Not Only SQL) 。 关系型数据库 是由多张能互相联接的二维行列表格组成的数据库

查看字符集、不同字符集之间迁移数据的可行性及风险说明

北慕城南 提交于 2020-12-30 10:49:58
目录 文档用途 详细信息 文档用途 本文说明了在瀚高数据库中查看数据库字符集、客户端字符集的方法,不同字符集之间迁移的方法及风险 详细信息 一、背景: 由于瀚高数据库/PostgreSQL数据库是多库结构,因此需要明确说明如下: 1.瀚高数据库/PostgreSQL数据库没有cluster(即:实例)层面的字符集。 2.瀚高数据库/PostgreSQL数据库的字符集是指瀚高数据库/PostgreSQL数据库cluster中某一个database的字符集。 3.本文所说的字符集是Encoding 瀚高数据库/PostgreSQL数据库支持的字符集见下: 名称 描述 语言 是否服务器端字符集 ICU? Bytes/Char 别名 BIG5 Big Five Traditional Chinese No No 1-2 WIN950 , Windows950 EUC_CN Extended UNIX Code-CN Simplified Chinese Yes Yes 1-3 EUC_JP Extended UNIX Code-JP Japanese Yes Yes 1-3 EUC_JIS_2004 Extended UNIX Code-JP, JIS X 0213 Japanese Yes No 1-3 EUC_KR Extended UNIX Code-KR Korean Yes

Are all class 40 errors normal in serializable transactions?

…衆ロ難τιáo~ 提交于 2020-12-30 08:14:11
问题 Some of my transactions are declared as SERIALIZABLE. Sometimes I get back class 40 errors such as 40001 serialization_failure and 40P01 deadlock_detected (I haven't seen other codes yet), particularly when I'm stress testing the system by doing lots of concurrent transactions. If I understood the manual correctly, this is to be expected. When these errors happen, I'm therefore suppose to retry the transaction. My doubt is whether all of class 40 errors are "normal" when handling SERIALIZABLE

Are all class 40 errors normal in serializable transactions?

人走茶凉 提交于 2020-12-30 08:11:46
问题 Some of my transactions are declared as SERIALIZABLE. Sometimes I get back class 40 errors such as 40001 serialization_failure and 40P01 deadlock_detected (I haven't seen other codes yet), particularly when I'm stress testing the system by doing lots of concurrent transactions. If I understood the manual correctly, this is to be expected. When these errors happen, I'm therefore suppose to retry the transaction. My doubt is whether all of class 40 errors are "normal" when handling SERIALIZABLE

PostgreSQL Bitwise operators with bit varying “cannot AND bit strings of different sizes”

霸气de小男生 提交于 2020-12-30 07:49:46
问题 I have a varying bitmask field and I want to perform a bitwise AND on it. PG::Error: ERROR: cannot AND bit strings of different sizes SELECT "groups".* FROM "groups" WHERE (read_roles_bitmask = B'0' OR read_roles_bitmask & B'10' > B'0') ( you need to have bitmasks with varying lengths in your table to get this error. ) I'm expecting the bitwise math to look like the following: 00010 & 100000010 = 00010 I've also tried casting the bitmask to a integer with no luck. Why does PostgreSQL choke on

PostgreSQL Bitwise operators with bit varying “cannot AND bit strings of different sizes”

江枫思渺然 提交于 2020-12-30 07:49:11
问题 I have a varying bitmask field and I want to perform a bitwise AND on it. PG::Error: ERROR: cannot AND bit strings of different sizes SELECT "groups".* FROM "groups" WHERE (read_roles_bitmask = B'0' OR read_roles_bitmask & B'10' > B'0') ( you need to have bitmasks with varying lengths in your table to get this error. ) I'm expecting the bitwise math to look like the following: 00010 & 100000010 = 00010 I've also tried casting the bitmask to a integer with no luck. Why does PostgreSQL choke on

PDO not throwing exception with unbound parameters (and no variables in query)

左心房为你撑大大i 提交于 2020-12-30 06:41:32
问题 So I have no idea what's going on here $link = new PDO('pgsql:dbname=' . $name . ';host=' . $host, $user, $password); $link->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); try { $stmt = $link->prepare("SELECT s.*, d.invalid_column FROM students s ORDER BY s.student_id"); $stmt->execute(array(1)); } catch (PDOException $e) { print $e->getMessage(); } When I run this little code example, I expect an exception to be thrown (as d