postgresql

Linq2db: effective way to query hierarchy of objects

泪湿孤枕 提交于 2021-01-05 11:09:57
问题 I'm using a c# and linq2db and have the following class/tables hierarchy: public class YearlyTemplate { [Column] public int Id { get; set; } public List<MonthlyTemplate> MonthlyTemplates { get; set;} } public class MonthlyTemplate { [Column] public int Id { get; set; } [Column] public int YearlyTemplateId { get; set; } public YearlyTemplate YearlyTemplate{ get; set; } public List<DailyTemplate> DailyTemplates { get; set;} } public class DailyTemplate { [Column] public int Id { get; set; }

YourSQLDba低版本的一个Bug的浅析

空扰寡人 提交于 2021-01-05 08:19:48
帮人分析解决一个YourSQLDba备份报错问题,个人觉得有点意思,顺手记录一下分析思路,大体解决思路如下: 首先,找到YourSQLDba作业YourSQLDba_FullBackups_And_Maintenance的报错邮件或者作业的错误日志信息,检查YourSQLDba出错的详细信息。 YOURSQLDBA.MAINT.ShowHistoryErrors 96 发现YourSQLDba在更新统计信息是遇到错误,如下所示 <Exec> <ctx>yMaint.UpdateStats</ctx> <inf>update statistics selected</inf> <cmd>update statistics [model].[dbo].[ServiceBrokerQueue] WITH sample 100 PERCENT</cmd> <err>Error 2706, Severity 16, level 6 : Table 'ServiceBrokerQueue' does not exist.</err> </Exec> 检查发现这个对象是queue,根本不是表,所以更新统计信息会出错。 那么YourSQLDba怎么会更新queue对象的统计信息呢?我首先检查了一下YourSQLDba的版本信息。当前数据库服务器上的YourSQLDba是相当老的一个版本了

Read amount on a postgres table

对着背影说爱祢 提交于 2021-01-05 07:43:10
问题 Is there any way to calculate the amount of read per second on a Postgres table? but what I need is that whether a table has any read at the moment. (If no, then I can safely drop it) Thank you 回答1: To figure out if the table is used currently, tun SELECT pid FROM pg_locks WHERE relation = 'mytable'::regclass; That will return the process ID of all backends using it. To measure whether s table is used at all or not, run this query: SELECT seq_scan + idx_scan + n_tup_ins + n_tup_upd + n_tup

ERROR: array must not contain nulls PostgreSQL

喜夏-厌秋 提交于 2021-01-05 07:10:49
问题 My Query is SELECT id, ARRAY_AGG(session_os)::integer[] FROM t GROUP BY id HAVING ARRAY_AGG(session_os)::integer[] && ARRAY[1,NULL] It's giving ERROR: array must not contain nulls Actually I want to get rows like id | Session_OS -------|------------- 641 | {1, 2} 642 | {NULL, 2} 643 | {NULL} Kindly check the sample data here https://dbfiddle.uk/?rdbms=postgres_13&fiddle=7793fa763a360bf7334787e4249d6107 回答1: The && operator does not support NULL values. So, you need another approach. For

ERROR: array must not contain nulls PostgreSQL

我是研究僧i 提交于 2021-01-05 07:09:33
问题 My Query is SELECT id, ARRAY_AGG(session_os)::integer[] FROM t GROUP BY id HAVING ARRAY_AGG(session_os)::integer[] && ARRAY[1,NULL] It's giving ERROR: array must not contain nulls Actually I want to get rows like id | Session_OS -------|------------- 641 | {1, 2} 642 | {NULL, 2} 643 | {NULL} Kindly check the sample data here https://dbfiddle.uk/?rdbms=postgres_13&fiddle=7793fa763a360bf7334787e4249d6107 回答1: The && operator does not support NULL values. So, you need another approach. For

开源软件联盟PostgreSQL分会喜迎中秋国庆

こ雲淡風輕ζ 提交于 2021-01-05 06:24:18
秋风送爽,丹桂飘香,雏菊绽放!伴随着开源软件联盟PostgreSQL分会的蓬勃发展,在这丰收的季节,我们迎来了一年一度的中秋国庆双佳节!中秋国庆喜相逢,小家大家情相通。 此时此刻在这万家团圆之际,举国欢庆之时,开源软件联盟PostgreSQL分会全体成员衷心的祝愿你和你的家人身体健康,万事如意,阖家欢乐! 感谢您这一年来对开源软件联盟PostgreSQL分会的关心和支持,借此佳节表达感谢。对此开源软件联盟PostgreSQL分会特别准备节日礼物等你来拿!参与活动, 说出开源软件联盟PostgreSQL分会对你印象最深刻的帮助 。扫描屏幕下方二维码关注公众号邀请更多小伙伴入盟,领取数据库资源! 活动时间:2020.9.30至10.01 温馨提示:关注并回复—祝PG分会节日快乐,参与活动哦! 开源软件联盟PostgreSQL分会 来源: oschina 链接: https://my.oschina.net/u/4584830/blog/4657090

Swapping column values in PostgreSQL

孤街浪徒 提交于 2021-01-05 05:48:13
问题 In my PostgreSQL database, I have a table with two text values, t1 and t2 : | id | t1 | t2 | | 1 | abcd | xyz | | 2 | aazz | rst | | 3 | fgh | qwerty | I would like to swap the values of the columns t1 and t2 for every row in the table in a way that, using the above example, this would be the result: | id | t1 | t2 | | 1 | xyz | abcd | | 2 | rst | aazz | | 3 | qwerty | fgh | Also, let's suppose the values from all rows with id=4 onwards (4, 5, 6...) are already correct, is it possible to

Swapping column values in PostgreSQL

十年热恋 提交于 2021-01-05 05:46:33
问题 In my PostgreSQL database, I have a table with two text values, t1 and t2 : | id | t1 | t2 | | 1 | abcd | xyz | | 2 | aazz | rst | | 3 | fgh | qwerty | I would like to swap the values of the columns t1 and t2 for every row in the table in a way that, using the above example, this would be the result: | id | t1 | t2 | | 1 | xyz | abcd | | 2 | rst | aazz | | 3 | qwerty | fgh | Also, let's suppose the values from all rows with id=4 onwards (4, 5, 6...) are already correct, is it possible to

数据库—从注入到提权的全家桶套餐

拈花ヽ惹草 提交于 2021-01-04 09:49:15
这是 酒仙桥六号部队 的第 55 篇文章。 全文共计5397个字,预计阅读时长17分钟 。 前言 偶然看到了最新的数据库流行度排名,发现在前5名的关系型数据库中,日常渗透测试见到最多的便是MySQL,排名第一的Oracle可能因为企业版高昂的价格限制了用户群众,在实际中相对于MySQL遇到的偏少,作为完全免费开源的PostgreSQL,虽然也占据了榜单Top 4,但目前在国内碰到的几率也很小。 所以这次先重点研究一下Oracle与PostgreSQL这两种数据库从手注到提权的不同方式,避免过度依赖sqlmap一把梭的尴尬局面。 SQL注入分析 1.数据库类型判断 身为关系型数据库,自然避免不了SQL注入的话题,而在进行注入前,我们首先要对数据库的种类进行判断 Oracle:根据特有的表进行判断: and ( select count (*) from sys.user_tables)> 0 PostgreSQL:根据特有的语法判断: and + 1 :: int = 1 -- 接下来我们从各自的数据库语法去分析不同的SQL注入方式,SQL注入按照我们熟悉的注入语法又划分为:基于布尔的盲注、基于时间延迟的盲注、显错注入、联合查询注入、堆查询注入,我们依次来对两种数据库进行分析。 2.联合查询注入 Oracle a.在Oracle中,存在dual虚拟表,任何用户都可以去读取查询

Postgre SQL ignore the filtering condition if the value is null

青春壹個敷衍的年華 提交于 2021-01-04 08:05:42
问题 I have the following three variables passed to the query A,B and C . A, B and C can take any values including null. When I run the below queryset, it should ignore the condition if the value in A,B or C is null queryset = User.objects.values().filter(A_name=A, B_name=B, C_name =C) For example, if C value passed in null then the query should behave like queryset = User.objects.values().filter(A_name=A, B_name=B) And if C and A value passed in null then the query should behave like queryset =