postgresql-9.5

will pg_restore overwrite the existing tables?

↘锁芯ラ 提交于 2019-12-06 19:01:11
问题 Say I have two host servers s1 and s2. In both the servers i have a schema named n1, now i have made some changes to some of the tables present in schema n1 of s1. I want the same change to be done to schema n1 of server s2. what i am planning to do is to take a backup of the schema n1 of server s1 using pg_dump and restore in the server s2 using pg_restore. Now my question is ,since there is already the same schema n1 in the server s2 with the same set of tables. what the restore process

rails g migrate with postgres prefixes commands with schema name

♀尐吖头ヾ 提交于 2019-12-06 06:02:37
问题 Haven't worked with postgres in a while and I'm running into this issue on an existing project I've just started working with. When I run rails g migrate , the command completes successfully; however, it generates a boatload of diffs on db/structure.sql . The differences are that the revised file explicitly prefixes every command with the postgres public schema. For example, I get many diffs like this: -CREATE TABLE customer ( +CREATE TABLE public.customer ( How can I suppress this behavior?

PostgreSQL 9.5 - update doesn't work when merging NULL with JSON

房东的猫 提交于 2019-12-06 04:01:30
问题 My users table contains a metadata column of type json . Now, I want to add new metadata to a user while preserving existing values. So I'm using the || operator to merge 2 JSON objects: UPDATE users SET metadata = metadata::jsonb || '{"test": true}'::jsonb WHERE id=... RETURNING *; Everything works fine when there are already some existing metadata. However, when the previous value is NULL then the update doesn't work. The metadata after update is still NULL . How can I improve my query so

Why isn't row level security enabled for Postgres views?

流过昼夜 提交于 2019-12-05 10:27:18
问题 I need strict control of the reading and writing of my Postgres data. Updatable views have always provided very good, strict, control of the reading of my data and allows me to add valuable computed columns. With Postgres 9.5 row level security has introduced a new and powerful way to control my data. But I can't use both technologies views, and row level security together. Why? 回答1: Basically because it wasn't possible to retroactively change how views work. I'd like to be able to support

Postgres Tutorial: pg_restore: [archiver] input file does not appear to be a valid archive

有些话、适合烂在心里 提交于 2019-12-05 05:18:42
I'm working through the Postgres DVD tutorial and am running into issues importing their sample database. Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar.gz gives me pg_restore: [archiver] input file does not appear to be a valid archive . My process so far has been the following: Download the dvdrental.zip file Extract it to a .tar using tar czf dvd-database.tar.gz dvdrental.zip (I've also tried extracting the zip to a folder first with the same result, as well as dropping the .gz) Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar as stated

will pg_restore overwrite the existing tables?

我是研究僧i 提交于 2019-12-05 00:07:56
Say I have two host servers s1 and s2. In both the servers i have a schema named n1, now i have made some changes to some of the tables present in schema n1 of s1. I want the same change to be done to schema n1 of server s2. what i am planning to do is to take a backup of the schema n1 of server s1 using pg_dump and restore in the server s2 using pg_restore. Now my question is ,since there is already the same schema n1 in the server s2 with the same set of tables. what the restore process will do? will it overwrite the existing tables or should i drop the existing schema of server s2 and

Postgres shuts down immediately when started with docker-compose

爷,独闯天下 提交于 2019-12-04 16:09:47
问题 Postgres shuts down immediately when started with docker-compose. The yaml file used is below version: '2' services: postgres: image: postgres:9.5 container_name: local-postgres9.5 ports: - "5432:5432" The log when docker-compose up command is executed Creating local-postgres9.5 Attaching to local-postgres9.5 local-postgres9.5 | The files belonging to this database system will be owned by user "postgres". local-postgres9.5 | This user must also own the server process. local-postgres9.5 |

rails g migrate with postgres prefixes commands with schema name

我的梦境 提交于 2019-12-04 10:10:36
Haven't worked with postgres in a while and I'm running into this issue on an existing project I've just started working with. When I run rails g migrate , the command completes successfully; however, it generates a boatload of diffs on db/structure.sql . The differences are that the revised file explicitly prefixes every command with the postgres public schema. For example, I get many diffs like this: -CREATE TABLE customer ( +CREATE TABLE public.customer ( How can I suppress this behavior? This looks to be caused by the a security patch in at least Postgresql 9.4.17 release from the 1st

PostgreSQL 9.5 - update doesn't work when merging NULL with JSON

随声附和 提交于 2019-12-04 08:26:35
My users table contains a metadata column of type json . Now, I want to add new metadata to a user while preserving existing values. So I'm using the || operator to merge 2 JSON objects: UPDATE users SET metadata = metadata::jsonb || '{"test": true}'::jsonb WHERE id=... RETURNING *; Everything works fine when there are already some existing metadata. However, when the previous value is NULL then the update doesn't work. The metadata after update is still NULL . How can I improve my query so that it sets the new JSON object when the previous value is NULL or merges the previous and new values

Are the rows locked in order in a SELECT … ORDER BY … FOR UPDATE statement?

时光毁灭记忆、已成空白 提交于 2019-12-04 07:27:30
This question can be considered as a follow-up on my comment on Can two concurrent but identical DELETE statements cause a deadlock? . I am wondering if the rows are locked in ascending my_status order in the following statement: SELECT 1 FROM my_table ORDER BY my_status FOR UPDATE; There is an interesting remark on https://www.postgresql.org/docs/9.5/static/sql-select.html which says: It is possible for a SELECT command running at the READ COMMITTED transaction isolation level and using ORDER BY and a locking clause to return rows out of order. This is because ORDER BY is applied first. The