p_mo
p_mo

Reputation: 77

Google Cloud SQL: Column Does Not Exist Error When Inserting Row

I have a SQL table on Google Cloud (which I will call table_name here). It has three columns, which I will refer to as:

  1. col_1 (with data type 'character varying')
  2. col_2 (with data type 'character varying')
  3. col_3 (with data type 'timestamp without time zone')

I am trying to enter a new row with the following query:

insert into table_name (col_1, col_2, col_3) 
values ("some_string", "some_string_2", "2021-08-01 04:28:00");

However, it is returning an error

column "some_string" does not exist

All of the data types should be correct, and I'm pretty sure the syntax of this query is correct, so what could be happening here?

Upvotes: 0

Views: 251

Answers (2)

p_mo
p_mo

Reputation: 77

I was able to fix this by using the query

INSERT INTO table_name VALUES ('some_string', 'some_string_2', TO_TIMESTAMP('2021-08-01 04:28:11', 'YYYY-MM-DD HH:MI:SS');

I will accept John Hanley's answer, though, as the double quotes were also an error.

Upvotes: 0

John Hanley
John Hanley

Reputation: 81336

Change double-quotes to single-quotes:

values ('some_string', 'some_string_2', '2021-08-01 04:28:00'); 

Double-quotes are not used to indicate strings in SQL. Enforcement varies with database vendors.

Upvotes: 3

Related Questions