postgresql-9.3

PostgreSQL 9.3: Pivot table query

泪湿孤枕 提交于 2019-12-06 00:12:46
I want to show the pivot table(crosstab) for the given below table. Table: Employee CREATE TABLE Employee ( Employee_Number varchar(10), Employee_Role varchar(50), Group_Name varchar(10) ); Insertion: INSERT INTO Employee VALUES('EMP101','C# Developer','Group_1'), ('EMP102','ASP Developer','Group_1'), ('EMP103','SQL Developer','Group_2'), ('EMP104','PLSQL Developer','Group_2'), ('EMP101','Java Developer',''), ('EMP102','Web Developer',''); Now I want to show the pivot table for the above data as shown below: Expected Result : Employee_Number TotalRoles TotalGroups Available Others Group_1

How to specify host name in pg_hba.conf file of postgresql?

守給你的承諾、 提交于 2019-12-05 19:53:01
We want to create a line like this : host all all vs1.nsdp.ir md5 in pg_hba.conf file. But it doesn't understand this host name. It's Ip is 192.168.1.60 and when we use ip address that's fine. But it won't work with host name. We created a reverse dns lookup in our dns server so it can be able to reverse lookup the ip of our domain and the problem is solved 来源: https://stackoverflow.com/questions/22374768/how-to-specify-host-name-in-pg-hba-conf-file-of-postgresql

Postgres UTC to Java ZonedDateTime

本小妞迷上赌 提交于 2019-12-05 19:43:58
Follow-up question to my original issue . Because I know that any date time used is against a known timezone, rather than where the user may be submitting their request from, I take a LocalDateTime, convert to UTC and persist. Then, when the appointment is retrieved I convert the saved time to the meeting location timezone (stored in db). However, it would seem that the values I save are actually being saved in my local timezone. I receive a date time value in the Rest Controller such as: startLocalDateTime: 2016-04-11T10:00 endLocalDateTime: 2016-04-11T10:30 Appointment has two ZoneDateTime

Postgres: Best way to move data from public schema of one DB to new schema of another DB

大兔子大兔子 提交于 2019-12-05 17:18:40
问题 I am new to Postgres and just discovered that I cannot access data of different databases in one SQL query. And also learned the concept of schema in Postgres. Now, I have two databases db1 and db2 Both have tables with same name in their public schema. Now, I want to create a new schema in db1 with name : new_schema And move data from db2.public to db1.new_schema What is the easiest way to do this ? 回答1: The simplest way to do that is to rename schemas. However you must be sure you are a

In pg_restore, how can you use a postgres connection string to specify the host/database/username/password?

自闭症网瘾萝莉.ら 提交于 2019-12-05 14:50:28
问题 When using pg_dump, you can use a postgres connection string to specify the host/database/username/password: pg_dump postgres://someuser:somepassword@somehost.com:5432/somedatabase I want to use the same sort of connection string for pg_restore: pg_restore -f dump.dump postgres://userb:somepassword@somehost.com:5432/otherdatabase But I get an error: pg_restore: [archiver] could not open input file "postgres://userb:somepassword@somehost.com:5432/otherdatabase": No such file or directory 回答1:

Different results for extract epoch on different PostgreSQL servers

谁说胖子不能爱 提交于 2019-12-05 14:42:25
We convert time stamps to epoch, do some math on them and then convert them back to time stamps. All times in the database are TIMESTAMP WITHOUT TIME ZONE . Since the switch to summer time here in the UK times are off by one hour on one server but not on the other so I did a little test: SHOW SERVER_VERSION; SHOW TIMEZONE; SELECT extract(EPOCH FROM TIMESTAMP '1970-01-01'); On one server I get server_version ---------------- 9.1.15 (1 row) TimeZone ---------- GB (1 row) date_part ----------- 0 (1 row) But on the other server_version ---------------- 9.3.6 (1 row) TimeZone ---------- GB (1 row)

postgresql 9.3 log slow queries

最后都变了- 提交于 2019-12-05 13:58:20
I am using Rails application with Postgres 9.3 database and doing some performance fixes. I would like to know how to find out slowest queries in log files. let say queries taking more then 30ms. In postgresql.conf you should uncomment line #log_min_duration_statement = -1 and change its value to 30. This way queries longer than 30ms will be logged 来源: https://stackoverflow.com/questions/41746897/postgresql-9-3-log-slow-queries

Centos 7 environment variables for Postgres service

那年仲夏 提交于 2019-12-05 08:54:36
Recently I had the problem of starting a postgresql service with custom PGDATA path. It tried to look in the default data directory (/var/lib/pgsql/9.3/data/) which was not initialized and therefore triggered these errors. It appears the problem is that the service starter on Centos 7 strips all the environment variables, including PGDATA. Interesting thread on the issue Is there a way to configure service postgresql-9.3 start to use custom environment variables? Are there configuration files for services where these variables have to be defined? Thank you in advance! Thanks for the above

How to install PL/Python on PostgreSQL 9.3 x64 Windows 7?

痞子三分冷 提交于 2019-12-05 08:00:00
I have tried to install the PL/Python v2.x language inside PostgreSQL on my database running the query: CREATE EXTENSION plpythonu; (I got this from http://www.postgresql.org/docs/9.3/static/plpython.html ) But I'm getting this error: ERRO: não pôde acessar arquivo "$libdir/plpython2": No such file or directory ********** Error ********** ERRO: não pôde acessar arquivo "$libdir/plpython2": No such file or directory SQL state: 58P01 How to install this in an automated way? I need to install it on many computers. Typically this error message is a misleading one emitted by the Windows API

Postgresql constraint to check for non-ascii characters

自闭症网瘾萝莉.ら 提交于 2019-12-05 05:59:29
I have a Postgresql 9.3 database that is encoded 'UTF8'. However, there is a column in database that should never contain anything but ASCII. And if non-ascii gets in there, it causes a problem in another system that I have no control over. Therefore, I want to add a constraint to the column. Note: I already have a BEFORE INSERT trigger - so that might be a good place to do the check. What's the best way to accomplish this in PostgreSQL? Craig Ringer You can define ASCII as ordinal 1 to 127 for this purpose, so the following query will identify a string with "non-ascii" values: SELECT exists