quoted-identifier

When do Postgres column or table names need quotes and when don't they?

谁说我不能喝 提交于 2019-11-28 02:25:42
Let's consider the following postgres query: SELECT * FROM "MY_TABLE" WHERE "bool_var"=FALSE AND "str_var"='something'; The query fails to respond properly when I remove quotes around "str_var" but not when I do the same around "bool_var" . Why? What is the proper way to write the query in that case, no quotes around the boolean column and quotes around the text column? Something else? Orysza Thanks to @TimBiegeleisen's comment, I was able to pinpoint the problem; I used a reserved keyword ("user") as a column name. Link to reserved keywords in the doc: https://www.postgresql.org/docs/current

I keep getting the error “relation [TABLE] does not exist”

為{幸葍}努か 提交于 2019-11-27 09:54:09
I have been trying to query two tables in my database. In the server explorer I can see both tables and even see the columns within them. We'll call them Schema.table1 and Schema.table2 where "Schema" has its first letter capitalized. I have tried running the following queries: select * from Schema.table1; Where I get the following error: ERROR: relation "schema.table1" does not exist I then tried running the next query thinking maybe the capitalization in the schema made a difference. Select * from "Schema.table1"; select "ID" from "Schema.table1"; But the same error persisted: ERROR:

Java SQL “ERROR: Relation ”Table_Name“ does not exist”

廉价感情. 提交于 2019-11-27 08:07:38
问题 I'm trying to connect netbeans to my postgresql database. The connection seems to have worked as I don't get any errors or exceptions when just connecting, methods such as getCatalog() also return the correct answers. But when I try to run a simple SQL statement I get the error "ERROR: relation "TABLE_NAME" does not exist", where TABLE_NAME is any one of my tables which DO exist in the database. Here's my code: Statement stmt = con.createStatement(); ResultSet rs; String query = "SELECT *

Error: Column does not exist

你说的曾经没有我的故事 提交于 2019-11-27 05:22:06
I have been able to link PostgreSQL to java. I have been able to display all the records in the table, however I unable to perform delete operation. Here is my code: con = DriverManager.getConnection(url, user, password); String stm = "DELETE FROM hostdetails WHERE MAC = 'kzhdf'"; pst = con.prepareStatement(stm); pst.executeUpdate(); Please note that MAC is a string field and is written in capital letters. This field does exist in the table. The error that I am getting: SEVERE: ERROR: column "mac" does not exist Jordan S. Jones When it comes to Postgresql and entity names (Tables, Columns, etc

Postgresql Column Not Found, But Shows in Describe

故事扮演 提交于 2019-11-27 04:55:53
问题 There have been similar posts, but none helped me solve my problem. I am trying to do a simple select on a table, retrieving only one column. The column shows in the describe table, but when I try to select it I get a column not found error. I am using the command line interface. Table: id | integer | not null default amazon_payment_id | integer | not null source | character varying(10) | not null timestamp | timestamp with time zone | not null status | character varying(50) | not null

Strange behaviour in Postgresql

蓝咒 提交于 2019-11-27 02:21:50
I'm new to Postgresql and I'm trying to migrate my application from MySQL. I have a table with the following structure: 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:

When do Postgres column or table names need quotes and when don't they?

旧街凉风 提交于 2019-11-26 18:39:51
问题 Let's consider the following postgres query: SELECT * FROM "MY_TABLE" WHERE "bool_var"=FALSE AND "str_var"='something'; The query fails to respond properly when I remove quotes around "str_var" but not when I do the same around "bool_var" . Why? What is the proper way to write the query in that case, no quotes around the boolean column and quotes around the text column? Something else? 回答1: PostgreSQL converts all names (table name, column names etc) into lowercase if you don't prevent it by

sql statement error: “column .. does not exist”

拥有回忆 提交于 2019-11-26 16:45:28
Im trying from postgres console this command: select sim.id as idsim, num.id as idnum from main_sim sim left join main_number num on (FK_Numbers_id=num.id); and I've got this response: ERROR: column "fk_numbers_id" does not exist LINE 1: ...m from main_sim sim left join main_number num on (FK_Numbers... but if I simply check my table with: dbMobile=# \d main_sim id | integer | not null default Iccid | character varying(19) | not null ... FK_Device_id | integer | FK_Numbers_id | integer | Indexes: "main_sim_pkey" PRIMARY KEY, btree (id) "main_sim_FK_Numbers_id_key" UNIQUE, btree ("FK_Numbers_id

PostgreSQL “Column does not exist” but it actually does

倾然丶 夕夏残阳落幕 提交于 2019-11-26 15:28:40
I'm writing a Java application to automatically build and run SQL queries. For many tables my code works fine but on a certain table it gets stuck by throwing the following exception: Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "continent" does not exist Hint: Perhaps you meant to reference the column "countries.Continent". Position: 8 The query that has been run is the following: SELECT Continent FROM network.countries WHERE Continent IS NOT NULL AND Continent <> '' LIMIT 5 This essentially returns 5 non-empty values from the column. I don't understand why I'm

Error: Column does not exist

我怕爱的太早我们不能终老 提交于 2019-11-26 12:47:53
问题 I have been able to link PostgreSQL to java. I have been able to display all the records in the table, however I unable to perform delete operation. Here is my code: con = DriverManager.getConnection(url, user, password); String stm = \"DELETE FROM hostdetails WHERE MAC = \'kzhdf\'\"; pst = con.prepareStatement(stm); pst.executeUpdate(); Please note that MAC is a string field and is written in capital letters. This field does exist in the table. The error that I am getting: SEVERE: ERROR: