我们有一个托管在 Azure 上的 postgres 数据库,我们想从“本地”postgres 数据库刷新它。
我不确定,最好的方法是什么?
通过增量备份然后增量还原或通过 Slony-I 复制,尽管我很确定 Azure 不存在此功能?
谢谢
我们有一个托管在 Azure 上的 postgres 数据库,我们想从“本地”postgres 数据库刷新它。
我不确定,最好的方法是什么?
通过增量备份然后增量还原或通过 Slony-I 复制,尽管我很确定 Azure 不存在此功能?
谢谢
我正在尝试为 postgres 服务器设置 Windows 身份验证。
这个过程没有很好的记录,使整个事情变得模糊不清。
我找到了这个文档,但还不清楚。
在必要的步骤中,文档说您需要创建域用户。然而在屏幕截图中,它说DomainServiceAccount
一旦您创建了域用户并使用域用户设置了 postgres 服务,您需要在 AD 服务器中使用以下命令行为您的服务帐户创建一个服务主体名称
setspn -S POSTGRES/[fully.qualified.domain.name] DOMAIN\[service_account_name]
问题如下
service_account_name
= DomaninServiceAccount
=Domain user
吗?SuperPostgres
,我设置了文档中提到的用户的服务SuperPostgres
,我使用命令行创建了一个 SPNspn
并设置了文档中提到的相关角色,是否确定Postgres 将允许 AD 用户喜欢AndyKw
连接到 postgres 数据库吗?我对 msaccess 有以下查询
SELECT Trim([T13_RefSupplier_France_List].[Supplier_code]) AS Supplier_code,
Trim([T13_RefSupplier_France_List].[Art]) AS Internal_reference,
Trim([fp_rcli]) AS Supplier_reference,
Last(Trim([ar_fami])) AS Family_code,
Last(Trim([fp_upri])) AS Purchasing_unit,
Last(Nz([fp_pcde],0)) AS Purchasing_price,
Last(Supplier_currency_France.Recode) AS Purchasing_currency,
Last("") AS Consigned,
Last(0) AS Eco_order_qty,
Last(CDbl(Nz(Nz([fp_cond],[ar_qcdi]),0))) AS Pack_order_qty,
Last(IIf([fp_minc]=0,Nz([fp_cond],[ar_qcdi]),[fp_minc])) AS Min_order_qty,
0 AS Min_order_value,
0 AS Product_grossweight,
0 AS Product_grosscube,
Last(gpfprodu_France.fp_dela) AS Leadtime_days,
Nz([Localisation_France].[Site],"Poitiers") AS Site,
CDbl(Nz([Active],-1)) AS Supplier_active,
Max(IIf([ar1_pdanz]=0,NULL,[ar1_pdanz])) AS Ref_price
FROM ((T13_RefSupplier_France_List
LEFT JOIN ((gparticl_France
LEFT JOIN Localisation_France ON gparticl_France.ar_loco=Localisation_France.Localisation)
LEFT JOIN [*gpartic1_France] ON gparticl_France.ar_code=[*gpartic1_France].ar1_code) ON T13_RefSupplier_France_List.Art=gparticl_France.ar_code)
LEFT JOIN ((gpfprodu_France
LEFT JOIN gpfourni_France ON gpfprodu_France.fp_four=gpfourni_France.fo_code)
LEFT JOIN Supplier_currency_France ON gpfourni_France.fo_monn=Supplier_currency_France.fo_monn) ON (T13_RefSupplier_France_List.Supplier_code=gpfprodu_France.fp_four)
AND (T13_RefSupplier_France_List.Art=gpfprodu_France.fp_arti))
LEFT JOIN T13_RefSupplier_France_SupplierActive ON (T13_RefSupplier_France_List.Art=T13_RefSupplier_France_SupplierActive.Art)
AND (T13_RefSupplier_France_List.Supplier_code=T13_RefSupplier_France_SupplierActive.Supplier_code)
GROUP BY Trim([T13_RefSupplier_France_List].[Supplier_code]),
Trim([T13_RefSupplier_France_List].[Art]),
Trim([fp_rcli]),
Nz([Localisation_France].[Site],"Poitiers"),
CDbl(Nz([Active],-1))
HAVING (((Trim(T13_RefSupplier_France_List.Supplier_code))<>"FG0002")
AND ((Trim(T13_RefSupplier_France_List.Art))<>"A60101000000000"));
我可以在GROUP BY
不使用具有LAST
函数的列的情况下执行操作,但是当我删除 LAST 函数时,我必须添加所有列GROUP BY
(见下文)。
SELECT Trim([T13_RefSupplier_France_List].[Supplier_code]) AS Supplier_code,
Trim([T13_RefSupplier_France_List].[Art]) AS Internal_reference,
Trim([fp_rcli]) AS Supplier_reference,
Trim([ar_fami]) AS Family_code,
Trim([fp_upri]) AS Purchasing_unit,
Nz([fp_pcde],0) AS Purchasing_price,
Supplier_currency_France.Recode AS Purchasing_currency,
"" AS Consigned,
0 AS Eco_order_qty,
CDbl(Nz(Nz([fp_cond],[ar_qcdi]),0)) AS Pack_order_qty,
IIf([fp_minc]=0,Nz([fp_cond],[ar_qcdi]),[fp_minc]) AS Min_order_qty,
0 AS Min_order_value,
0 AS Product_grossweight,
0 AS Product_grosscube,
gpfprodu_France.fp_dela AS Leadtime_days,
Nz([Localisation_France].[Site],"Poitiers") AS Site,
CDbl(Nz([Active],-1)) AS Supplier_active,
Max(IIf([ar1_pdanz]=0,NULL,[ar1_pdanz])) AS Ref_price
FROM ((T13_RefSupplier_France_List
LEFT JOIN ((gparticl_France
LEFT JOIN Localisation_France ON gparticl_France.ar_loco=Localisation_France.Localisation)
LEFT JOIN [*gpartic1_France] ON gparticl_France.ar_code=[*gpartic1_France].ar1_code) ON T13_RefSupplier_France_List.Art=gparticl_France.ar_code)
LEFT JOIN ((gpfprodu_France
LEFT JOIN gpfourni_France ON gpfprodu_France.fp_four=gpfourni_France.fo_code)
LEFT JOIN Supplier_currency_France ON gpfourni_France.fo_monn=Supplier_currency_France.fo_monn) ON (T13_RefSupplier_France_List.Supplier_code=gpfprodu_France.fp_four)
AND (T13_RefSupplier_France_List.Art=gpfprodu_France.fp_arti))
LEFT JOIN T13_RefSupplier_France_SupplierActive ON (T13_RefSupplier_France_List.Art=T13_RefSupplier_France_SupplierActive.Art)
AND (T13_RefSupplier_France_List.Supplier_code=T13_RefSupplier_France_SupplierActive.Supplier_code)
GROUP BY Trim([T13_RefSupplier_France_List].[Supplier_code]),
Trim([T13_RefSupplier_France_List].[Art]),
Trim([fp_rcli]),
Nz([Localisation_France].[Site],"Poitiers"),
Trim([ar_fami]),
Trim([fp_upri]),
Nz([fp_pcde],0),
Supplier_currency_France.Recode,
"",
0,
CDbl(Nz(Nz([fp_cond],[ar_qcdi]),0)),
IIf([fp_minc]=0,Nz([fp_cond],[ar_qcdi]),[fp_minc]),
0,
0,
0,
gpfprodu_France.fp_dela,
CDbl(Nz([Active],-1))
HAVING (((Trim(T13_RefSupplier_France_List.Supplier_code))<>"FG0002")
AND ((Trim(T13_RefSupplier_France_List.Art))<>"A60101000000000"));
问题有两个:
LAST
?LAST
函数转置到 SQLServer:我应该怎么做?谢谢
我正在尝试在法兰克福托管的 Postgres RDS 数据库中创建一个触发器,我们将其称为“法兰克福”。该触发器将轮询位于首尔的远程 Postgres RDS 数据库中的表,我们称该数据库为“首尔”。
首尔数据库永远不会删除或更新。它只会有插入。
该触发器的目的是为首尔数据库中的每个插入将不在法兰克福的行从首尔复制到法兰克福数据库。
CREATE OR REPLACE FUNCTION my_dml_function() RETURNS TRIGGER AS $employees$
BEGIN
--
--
IF (TG_OP = 'INSERT') THEN
perform dblink_connect('dbname=database_seoul user=postgres password=ExtraPassword');
INSERT INTO all_employees
SELECT *
FROM dblink('foreign_server',$RDS$
SELECT *
FROM employees
WHERE employee_id NOT IN (SELECT employee_id FROM all_employees)
$RDS$) AS t1;
END IF;
RETURN NULL; -- result is ignored since this is an AFTER trigger
END;
$emp_audit$ LANGUAGE plpgsql;
CREATE TRIGGER my_dml_trigger
AFTER INSERT OR UPDATE OR DELETE ON employees
FOR EACH ROW EXECUTE PROCEDURE my_dml_function();
我不确定这是否是最好的方法。
我正在尝试在位于 Amazon rds 的 postgres 实例上创建模式。
该模式将用于从基于本地数据库的现有模式导入数据。
问题是我无权在 RDS 上创建模式。
dw_etl
我用来连接 postgres 实例的用户具有角色rds_superuser
,与superuser
角色相似。dw_etl
应该能够创建新的模式。
问题:
public
变成某种转储吗?谢谢
我在 Access 中有下表
当您在第一列和第二列上过滤时,我有很多行存在重复。我需要删除这些重复项。我发现的最好方法是使用row_number
.
我想在 Microsoft Access 中模拟这个 Postgres 查询的等效项:
SELECT
"Supplier_code",
"Internal_reference",
"Supplier_reference",
"Family_code",
"Purchasing_unit",
"Purchasing_price",
"Purchasing_currency",
"Consigned",
"Eco_order_qty",
"Pack_order_qty",
"Min_order_qty",
"Min_order_value",
"Product_grossweight",
"Product_grosscube",
"Leadtime_days",
"Supplier_active",
ROW_NUMBER() OVER (PARTITION BY "Supplier_code", "Internal_reference"
ORDER BY "Internal_reference") AS "cnt"
FROM dw.T13_RefSupplier_Mexico_ToXL
我在网上看了一下,在 Stack Overflow 上找到了这个,但我不确定从哪里开始:
这个表是缓冲表,没有PK。必须从此表中清除所有重复数据。完成后,它将转到主表,其中Supplier_code
&Internal_reference
是 PK 的一部分。
我构建了这个查询,但它没有达到我想要的效果:
SELECT
t1.Supplier_code,
t1.Internal_reference,
t1.Supplier_reference,
t1.Family_code,
t1.Purchasing_unit,
t1.Purchasing_price,
t1.Purchasing_currency,
t1.Consigned,
t1.Eco_order_qty,
t1.Pack_order_qty,
t1.Min_order_qty,
t1.Min_order_value,
t1.Product_grossweight,
t1.Product_grosscube,
t1.Leadtime_days,
t1.Supplier_active,
COUNT(*) AS [Ino]
FROM
T13_RefSupplier_Mexico_ToXL AS t1
INNER JOIN
T13_RefSupplier_Mexico_ToXL AS t2
ON t2.Supplier_code = t1.Supplier_code
AND t2.Purchasing_price <= t1.Purchasing_price
GROUP BY
t1.Supplier_code,
t1.Internal_reference,
t1.Supplier_reference,
t1.Family_code,
t1.Purchasing_unit,
t1.Purchasing_price,
t1.Purchasing_currency,
t1.Consigned,
t1.Eco_order_qty,
t1.Pack_order_qty,
t1.Min_order_qty,
t1.Min_order_value,
t1.Product_grossweight,
t1.Product_grosscube,
t1.Leadtime_days,
t1.Supplier_active
ORDER BY 1, 2
请在下面找到我的数据的摘录
Supplier_code;Internal_reference;Supplier_reference;Family_code;Purchasing_unit;Purchasing_price;Purchasing_currency;Consigned;Eco_order_qty;Pack_order_qty;Min_order_qty;Min_order_value;Product_grossweight;Product_grosscube;Leadtime_days;Supplier_active;
T040;16-0022;;401;EA;0.072;USD;0;0;;;;;;42;1;
T040;50-0595A;;401;EA;0.163;USD;0;0;;;;;;42;1;
T070;50-0672;;131;EA;0.0693;USD;0;0;;;;;;63;1;
T070;50-0673;;131;EA;0.0755;USD;0;0;;;;;;63;1;
T070;50-0687;;131;EA;0.1097;USD;0;0;;;;;;63;1;
T070;50-0688;;131;EA;0.0899;USD;0;0;;;;;;63;1;
T070;50-0738;;131;EA;0.124;USD;0;0;;;;;;0;1;
T080;16-0067;;402;EA;0.47;EUR;0;0;;;;;;0;1;
T080;16-0067;;402;EA;0.47;USD;0;0;;;;;;0;1;
T900;53-2008;;391;EA;0.039;USD;0;0;;;;;;63;1;
T900;53-2008;;391;EA;0.033;USD;0;0;;;;;;63;1;
期望的结果可以是解决方案,其中删除了重复项
Supplier_code;Internal_reference;Supplier_reference;Family_code;Purchasing_unit;Purchasing_price;Purchasing_currency;Consigned;Eco_order_qty;Pack_order_qty;Min_order_qty;Min_order_value;Product_grossweight;Product_grosscube;Leadtime_days;Supplier_active;
T040;16-0022;;401;EA;0.072;USD;0;0;;;;;;42;1;
T040;50-0595A;;401;EA;0.163;USD;0;0;;;;;;42;1;
T070;50-0672;;131;EA;0.0693;USD;0;0;;;;;;63;1;
T070;50-0673;;131;EA;0.0755;USD;0;0;;;;;;63;1;
T070;50-0687;;131;EA;0.1097;USD;0;0;;;;;;63;1;
T070;50-0688;;131;EA;0.0899;USD;0;0;;;;;;63;1;
T070;50-0738;;131;EA;0.124;USD;0;0;;;;;;0;1;
T080;16-0067;;402;EA;0.47;EUR;0;0;;;;;;0;1;
T900;53-2008;;391;EA;0.039;USD;0;0;;;;;;63;1;
或者标记重复项的解决方案
Supplier_code;Internal_reference;Supplier_reference;Family_code;Purchasing_unit;Purchasing_price;Purchasing_currency;Consigned;Eco_order_qty;Pack_order_qty;Min_order_qty;Min_order_value;Product_grossweight;Product_grosscube;Leadtime_days;Supplier_active;Duplicate
T040;16-0022;;401;EA;0.072;USD;0;0;;;;;;42;1;1
T040;50-0595A;;401;EA;0.163;USD;0;0;;;;;;42;1;1
T070;50-0672;;131;EA;0.0693;USD;0;0;;;;;;63;1;1
T070;50-0673;;131;EA;0.0755;USD;0;0;;;;;;63;1;1
T070;50-0687;;131;EA;0.1097;USD;0;0;;;;;;63;1;1
T070;50-0688;;131;EA;0.0899;USD;0;0;;;;;;63;1;1
T070;50-0738;;131;EA;0.124;USD;0;0;;;;;;0;1;1
T080;16-0067;;402;EA;0.47;EUR;0;0;;;;;;0;1;1
T080;16-0067;;402;EA;0.47;USD;0;0;;;;;;0;1;2
T900;53-2008;;391;EA;0.039;USD;0;0;;;;;;63;1;1
T900;53-2008;;391;EA;0.033;USD;0;0;;;;;;63;1;2
我无法在查询中创建自动增量,因为它不是真正的表,更多的是查询的结果。参见Access中的图片:
我正在尝试在接收数据库上没有适当角色的情况下恢复转储。
如here和here所述,您需要将the--no-owner
作为一个选项,或者在其中pg_dump
或pg_restore
两者中。
我使用以下命令行来创建我的转储:
"C:\Program Files\PostgreSQL\9.3\bin\pg_dump.exe" --no-owner -Ft --dbname=postgresql://avo******:AV0******[email protected]:5432/BI_DB > K:\BI\backup\sort\bck_%timestamp%.tar
恢复线如下:
"C:\Program Files\PostgreSQL\9.3\bin\pg_restore.exe" --host localhost --port 5432 --username "postgres" --dbname "BI_TEST2" --no-password --no-owner --role=postgres --exit-on-error --verbose "D:\D\avo\backup\bck_04042017_1410.tar"
如您所见,两者都可以--no-owner
选择,但最终出现以下错误:
让我非常烦恼的是下面的日志:
pg_restore: [programme d'archivage (db)] Erreur pendant le traitement de la TOC (« PROCESSING TOC ») :
pg_restore: [programme d'archivage (db)] Erreur à partir de l'entrée TOC 2633 ; 0 0 ACL adm avo******
pg_restore: [programme d'archivage (db)] could not execute query: ERREUR: role « avo****** » does not exist
为什么即使指定了角色,它也说它需要一个角色--no-owner
?
我错过了什么?
我在 Postgres 9.3 上运行
我在互联网上没有发现任何关于使用 raid1 备份 postgres 数据库的相关信息。所以这是我的问题
我的系统管理员认为备份 Postgres 数据库所在的 raid1 磁盘作为 Postgres 备份就足够了。他会在需要时恢复它。
据我了解,备份需要停止数据库,至少对于像 Oracle 这样的商业数据库。
是否可以在 raid1 场景下不停止数据库的情况下进行备份?
谢谢