我正在尝试运行以下PHP脚本来执行简单的数据库查询:
$db_host = "localhost";
$db_name = "showfinder";
$username = "user";
$password = "password";
$dbconn = pg_connect("host=$db_host dbname=$db_name user=$username password=$password")
or die('Could not connect: ' . pg_last_error());
$query = 'SELECT * FROM sf_bands LIMIT 10';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
Run Code Online (Sandbox Code Playgroud)
这会产生以下错误:
查询失败:错误:关系"sf_bands"不存在
在所有的例子中,我可以找到有人得到错误的地方,说明关系不存在,这是因为他们在表名中使用大写字母.我的表名没有大写字母.有没有办法查询我的表而不包括数据库名称,即showfinder.sf_bands?
我有一个db表说,persons在Postgres中由另一个有列名称的团队传下来,"first_Name".现在我正在尝试使用PG指令器在此列名称上查询此表.
select * from persons where first_Name="xyz";
Run Code Online (Sandbox Code Playgroud)
它只是回归
错误:列"first_Name"不存在
不确定我是在做一些愚蠢的事情,还是我找不到这个问题的解决方法?
我是Postgresql的新手,我正在尝试从MySQL迁移我的应用程序.
我有一个具有以下结构的表:
Table "public.tbl_point"
Column | Type | Modifiers | Storage | Description
------------------------+-----------------------+-----------+----------+-------------
Tag_Id | integer | not null | plain |
Tag_Name | character varying(30) | not null | extended |
Quality | integer | not null | plain |
Execute | integer | not null | plain |
Output_Index | integer | not null | plain |
Last_Update | abstime | | plain |
Indexes:
"tbl_point_pkey" PRIMARY KEY, btree ("Tag_Id")
Triggers:
add_current_date_to_tbl_point BEFORE UPDATE ON tbl_point FOR …Run Code Online (Sandbox Code Playgroud)