小编qua*_*ack的帖子

如何在PostgreSQL中显示点后2位数字?

我有一张表,它们的值是NUMERIC(16,4)

例子:

12.4568
13.2
14.05
Run Code Online (Sandbox Code Playgroud)

我想在不四舍五入的情况下仅显示点后 2 位数字的值。预期结果是:

12.45
13.2
14.05
Run Code Online (Sandbox Code Playgroud)

我所做的是:

Select price::Numeric(16,2)
from prices
Run Code Online (Sandbox Code Playgroud)

它有效,但我不确定这是否是正确的方法。我认为使用某种显示编辑而不是投射更好?

sql postgresql numeric number-formatting

9
推荐指数
1
解决办法
2万
查看次数

openssl中的某些椭圆曲线给出“无共享密码”错误

当使用openssl s_server / s_client组合时,生成密钥对的某些曲线似乎不起作用。我已经使用以下方法验证了这一点:

  • 使用创建一个椭圆曲线键对openssl ecparam -out ec_$curve.key -name $curve -genkey,foreach $curveinopenssl ecparam -list_curves

  • 生成每个自签名证书ec_$curve.keyopenssl req -x509 -new -days 365 -key ec_$curve.key -out ec_$curve.crt -subj $SOME_SUBJ

  • 每一个ec_$curve.key,这样做:在一个窗口中,openssl s_server -cert ec_$curve.crt -key ec_$curve.key -accept 10000另一openssl s_client -host localhost -port 10000

我握手:

Using default temp DH parameters Using default temp ECDH parameters ACCEPT ERROR 8606155664:error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher:s3_srvr.c:1355: shutting down SSL CONNECTION CLOSED

对于使用以下的曲线创建的密钥对:所述c2.*曲线(例如,c2pnb163v1), …

openssl

5
推荐指数
1
解决办法
2386
查看次数

array_append 函数不起作用

我需要将一个项目附加到 postgresql 中的现有数组中。我写了这段代码(plpgsql函数):

perform array_append (arrayA::integer[],id);
Run Code Online (Sandbox Code Playgroud)

由于它不起作用,我尝试了:

raise notice '%', arrayA;
perform array_append (arrayA::integer[],id);
raise notice '%', arrayA;
Run Code Online (Sandbox Code Playgroud)

它给:

NOTICE:  <NULL>
NOTICE:  <NULL>
Run Code Online (Sandbox Code Playgroud)

为什么数组没有更新?

postgresql

2
推荐指数
1
解决办法
2233
查看次数

如何从表中删除某些列(但不是全部)在postgresql中重复的行?

我读过以前的问题,但它们与我的不相似(例如,我没有唯一的标识符).

说这是我的表行:

  id     string       x    y    z    time_x                 
10318    'hello'   33700  5053  8  2015-07-03 12:39:49.61408
14071    'hello'   33700  5053  8  2015-07-03 12:39:49.61408
Run Code Online (Sandbox Code Playgroud)

基本上一切都是相同的,除了行的id.如何识别这些情况并删除冗余行?

注意:并非表中的所有行都是重复的.应保留常规行.

sql postgresql

1
推荐指数
1
解决办法
56
查看次数

标签 统计

postgresql ×3

sql ×2

number-formatting ×1

numeric ×1

openssl ×1