postgresql

Connecting to local instance of PostgreSql with JDBC

大憨熊 提交于 2021-02-06 09:47:28
问题 I have a running local instance of PostgreSql on a linux machine. When I use psql command from the shell I success to log in without any problem. I need to connect to the PostgreSql via the JDBC, but I don't know what exactly should I pass as url parameter to DriverManager.getConnection() . It should start with jdbc:postgresql: but what's going next? I was told by the system group that a database with was created like user name. e.g. if my user is jutky a db named jutky was created, but when

Retrieving full hierarchy sorted by a column under PostgreSQL's Ltree module

随声附和 提交于 2021-02-06 09:12:35
问题 I'm using PostgreSQL's Ltree module for storing hierarchical data. I'm looking to retrieve the full hierarchy sorted by a particular column. Consider the following table: votes | path | ... -------+-------+----- 1 | 1 | ... 2 | 1.1 | ... 4 | 1.2 | ... 1 | 1.2.1 | ... 3 | 2 | ... 1 | 2.1 | ... 2 | 2.1.1 | ... 4 | 2.1.2 | ... ... | ... | ... In my current implementation, I'd query the database with SELECT * FROM comments ORDER BY path , which would return the whole tree: Node 1 -- Node 1.1 --

Retrieving full hierarchy sorted by a column under PostgreSQL's Ltree module

余生颓废 提交于 2021-02-06 09:12:34
问题 I'm using PostgreSQL's Ltree module for storing hierarchical data. I'm looking to retrieve the full hierarchy sorted by a particular column. Consider the following table: votes | path | ... -------+-------+----- 1 | 1 | ... 2 | 1.1 | ... 4 | 1.2 | ... 1 | 1.2.1 | ... 3 | 2 | ... 1 | 2.1 | ... 2 | 2.1.1 | ... 4 | 2.1.2 | ... ... | ... | ... In my current implementation, I'd query the database with SELECT * FROM comments ORDER BY path , which would return the whole tree: Node 1 -- Node 1.1 --

Retrieving full hierarchy sorted by a column under PostgreSQL's Ltree module

你。 提交于 2021-02-06 09:09:33
问题 I'm using PostgreSQL's Ltree module for storing hierarchical data. I'm looking to retrieve the full hierarchy sorted by a particular column. Consider the following table: votes | path | ... -------+-------+----- 1 | 1 | ... 2 | 1.1 | ... 4 | 1.2 | ... 1 | 1.2.1 | ... 3 | 2 | ... 1 | 2.1 | ... 2 | 2.1.1 | ... 4 | 2.1.2 | ... ... | ... | ... In my current implementation, I'd query the database with SELECT * FROM comments ORDER BY path , which would return the whole tree: Node 1 -- Node 1.1 --

Retrieving full hierarchy sorted by a column under PostgreSQL's Ltree module

℡╲_俬逩灬. 提交于 2021-02-06 09:07:25
问题 I'm using PostgreSQL's Ltree module for storing hierarchical data. I'm looking to retrieve the full hierarchy sorted by a particular column. Consider the following table: votes | path | ... -------+-------+----- 1 | 1 | ... 2 | 1.1 | ... 4 | 1.2 | ... 1 | 1.2.1 | ... 3 | 2 | ... 1 | 2.1 | ... 2 | 2.1.1 | ... 4 | 2.1.2 | ... ... | ... | ... In my current implementation, I'd query the database with SELECT * FROM comments ORDER BY path , which would return the whole tree: Node 1 -- Node 1.1 --

Postgres client locking up when creating new table

怎甘沉沦 提交于 2021-02-06 08:58:06
问题 I'm trying to create a new table in postgres but when I do it just hangs after the CREATE TABLE call. $ sudo usermod -s /bin/bash postgres $ sudo su - postgres postgres@host:~$ psql ranking_analytics psql (8.4.8) Type "help" for help. ranking_analytics=# BEGIN; BEGIN ranking_analytics=# CREATE TABLE "about_contactmessage" ( ranking_analytics(# "id" serial NOT NULL PRIMARY KEY, ranking_analytics(# "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, ranking

Postgres client locking up when creating new table

孤人 提交于 2021-02-06 08:57:27
问题 I'm trying to create a new table in postgres but when I do it just hangs after the CREATE TABLE call. $ sudo usermod -s /bin/bash postgres $ sudo su - postgres postgres@host:~$ psql ranking_analytics psql (8.4.8) Type "help" for help. ranking_analytics=# BEGIN; BEGIN ranking_analytics=# CREATE TABLE "about_contactmessage" ( ranking_analytics(# "id" serial NOT NULL PRIMARY KEY, ranking_analytics(# "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, ranking

Postgres client locking up when creating new table

隐身守侯 提交于 2021-02-06 08:57:03
问题 I'm trying to create a new table in postgres but when I do it just hangs after the CREATE TABLE call. $ sudo usermod -s /bin/bash postgres $ sudo su - postgres postgres@host:~$ psql ranking_analytics psql (8.4.8) Type "help" for help. ranking_analytics=# BEGIN; BEGIN ranking_analytics=# CREATE TABLE "about_contactmessage" ( ranking_analytics(# "id" serial NOT NULL PRIMARY KEY, ranking_analytics(# "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, ranking

Postgres client locking up when creating new table

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-06 08:56:23
问题 I'm trying to create a new table in postgres but when I do it just hangs after the CREATE TABLE call. $ sudo usermod -s /bin/bash postgres $ sudo su - postgres postgres@host:~$ psql ranking_analytics psql (8.4.8) Type "help" for help. ranking_analytics=# BEGIN; BEGIN ranking_analytics=# CREATE TABLE "about_contactmessage" ( ranking_analytics(# "id" serial NOT NULL PRIMARY KEY, ranking_analytics(# "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, ranking

How to set default display mode in psql

巧了我就是萌 提交于 2021-02-06 06:54:26
问题 Almost every psql query comes out an illegible mess if not preceded by display configuration commands such as \x auto . Typing this manually for each psql instance is annoying. Expanded display is used automatically. Is there any way to configure a better default display? Or perhaps the answer is to use a more advanced interactive terminal? 回答1: Use .psqlrc to set defaults. For the specific case of \x , newer psql versions (9.3, I think, but it might just be the 9.4 pre-release) can