postgresql

Error: invalid input syntax for integer: “”

£可爱£侵袭症+ 提交于 2021-02-18 11:12:14
问题 I have this table tbl_buku : id_buku judul_buku tahun_buku 1 Bioogi 2010 2 Fisika 2010 3 Informatika 2012 4 Kimia 2012 I use query like this, but I am getting an error: select case when t1.tahun_buku=t2.tahun_buku then '' else t1.tahun_buku end tahun_buku,t1.judul_buku from tbl_buku t1 left join tbl_buku t2 on t1.id_buku-1=t2.id_buku; I want to show table like this: tahun_buku judul_buku 2010 Biologi Fisika 2012 Informatika Kimia How to achieve this? 回答1: I think the problem in your query is

Error: invalid input syntax for integer: “”

為{幸葍}努か 提交于 2021-02-18 11:12:07
问题 I have this table tbl_buku : id_buku judul_buku tahun_buku 1 Bioogi 2010 2 Fisika 2010 3 Informatika 2012 4 Kimia 2012 I use query like this, but I am getting an error: select case when t1.tahun_buku=t2.tahun_buku then '' else t1.tahun_buku end tahun_buku,t1.judul_buku from tbl_buku t1 left join tbl_buku t2 on t1.id_buku-1=t2.id_buku; I want to show table like this: tahun_buku judul_buku 2010 Biologi Fisika 2012 Informatika Kimia How to achieve this? 回答1: I think the problem in your query is

pg_config shows 9.4 instead of 9.3

。_饼干妹妹 提交于 2021-02-18 11:06:50
问题 I am using Postgres 9.3, however my pg_config points at 9.4, preventing me from building extensions (pgTap). $ sudo aptitude search postgresql | grep ^i i postgresql-9.3 - object-relational SQL database, version 9. i postgresql-client-9.3 - front-end programs for PostgreSQL 9.3 i A postgresql-client-common - manager for multiple PostgreSQL client ver i A postgresql-common - PostgreSQL database-cluster manager i postgresql-contrib-9.3 - additional facilities for PostgreSQL As you can see above

2017-2018-2 20179226 《网络攻防》第11周作业

冷暖自知 提交于 2021-02-18 10:45:20
研究缓冲区溢出的原理,至少针对两种数据库进行差异化研究 原理 在计算机内部,输入数据通常被存放在一个临时空间内,这个临时存放的空间就被称为缓冲区,缓冲区的长度事先已经被程序或者操作系统定义好了。向缓冲区内填充数据,如果数据的长度很长,超过了缓冲区本身的容量,那么数据就会溢出存储空间,而这些溢出的数据还会覆盖在合法的数据上,这就是缓冲区和缓冲区溢出的道理。 对抗缓冲区溢出攻击 1、栈随机化   为了在系统中插入攻击代码,攻击者不但要插入代码,还要插入指向这段代码的指针,这个指针也是攻击字符串的一部分。产生这个指针需要知道这个字符串放置的栈地址。在过去,程序的栈地址非常容易预测,在不同的机器之间,栈的位置是相当固定的。 栈随机化的思想使得栈的位置在程序每次运行时都有变化。因此,即使许多机器都运行相同的代码。它们的栈地址都是不同的。 实现的方式是:程序开始时,在栈上分配一段0--n字节之间的随机大小空间。程序不使用这段空间,但是它会导致程序每次执行时后续的栈位置发生了变化。 在Linux系统中,栈随机化已经变成了标准行为。(在linux上每次运行相同的程序,其同一局部变量的地址都不相同) 2、栈破坏检测   在C语言中,没有可靠的方法来防止对数组的越界写,但是,我们能够在发生了越界写的时候,在没有造成任何有害结果之前,尝试检测到它。 最近的GCC版本在产生的代码中加入了一种栈保护者机制

Docker Compose and Postgres : Name does not resolve

坚强是说给别人听的谎言 提交于 2021-02-18 10:36:25
问题 In Docker, I am trying to configure Postgres, get it up and running in another container, and link it to my users service, set up with the following structure: docker-compose-dev.yml services/ users/ manage.py Dockerfile-dev entrypoint.sh project/ __init__.py config.py db/ create.sql Dockerfile docker-compose-dev.yml version: '3.7' services: users: build: context: ./services/users dockerfile: Dockerfile-dev volumes: - './services/users:/usr/src/app' ports: - 5001:5000 environment: - FLASK_APP

How to limit the maximum display length of a column in PostgreSQL

随声附和 提交于 2021-02-18 10:25:32
问题 I am using PostgreSQL, and I have a column in a table which contains very long text. I want to select this column in a query, but limit its display length. Something like: select longcolumn (only 10 chars) from mytable; How would I do this? 回答1: What you can do is use PostgreSQL's substring() method. Either one of the two commands below will work: SELECT substring(longcolumn for 10) FROM mytable; SELECT substring(longcolumn from 1 for 10) FROM mytable; 回答2: Slightly shorter: SELECT left

PostgreSQL ilike with multiple matches in Rails ActiveRecord

北城以北 提交于 2021-02-18 06:08:27
问题 I am trying to retrieve multiple records from my DB with the following query: User.where('name ilike ?','%thomas%') this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect): User.where('name ilike any',['%thomas%','%james%','%martin%']) What am I doing wrong? So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for. 回答1: You can do it by User.where('name

PostgreSQL ilike with multiple matches in Rails ActiveRecord

ⅰ亾dé卋堺 提交于 2021-02-18 06:07:44
问题 I am trying to retrieve multiple records from my DB with the following query: User.where('name ilike ?','%thomas%') this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect): User.where('name ilike any',['%thomas%','%james%','%martin%']) What am I doing wrong? So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for. 回答1: You can do it by User.where('name

PostgreSQL ilike with multiple matches in Rails ActiveRecord

最后都变了- 提交于 2021-02-18 06:07:33
问题 I am trying to retrieve multiple records from my DB with the following query: User.where('name ilike ?','%thomas%') this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect): User.where('name ilike any',['%thomas%','%james%','%martin%']) What am I doing wrong? So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for. 回答1: You can do it by User.where('name

How to add parameter values to pgadmin sql query?

梦想的初衷 提交于 2021-02-18 04:08:51
问题 In pgadmin3, I would like to use parameterized queries (to faster debugging, just copy & paste the query from my php file). But I haven't found an option to add the values of the $1 , $2 ... parameters. Is it possible? This is the query I'm building in a loop, following the suggestion for NULL testing from here: SELECT EXISTS(SELECT 1 FROM tax WHERE (addby=$1 or addby<>$1) AND (adddate=$2 or adddate<>$2) AND ($3 IS NULL AND nome IS NULL OR nome=$3) AND ($4 IS NULL AND rank IS NULL OR rank=$4)