Postgresql How to Insert a Value With Double Quotes Inside Double Quotes

Postgres - escape double quotes inside escaped double quotes

Double escape the double quotes by putting an escaped backslash in front:

\"hello \\\"world\\\"\"

How to insert a value to postgres database column which contains double quotes and triple quotes

Use dollar quoting:

UPDATE reports
SET raw_query = $${"enrolled_time":'''SELECT DISTINCT enrolled_time AT TIME ZONE %s FROM alluser'''}$$
WHERE id = 37;

psql insert json with double quotes inside strings

In a database command to escape a single quote you need to double it:

test=> insert into test values ('{"a": 1, "b": "1'' 2\""}');

Duplicate quotes in a postgres string

Assuming you expect only one single quote (and not double or more), you could try using a simple replace:

UPDATE yourTable
SET email = REPLACE(email, '''', '''''');

Inserting into Postgres DB using double quotes isn't working

Try below: you need to use single quote twice in case of apostrophi like let's will be let''s

INSERT INTO interactions (fbid,date,time,event) VALUES ('senderid','2018-09- 
28','10:50:07','Let''s chat')

How to insert paranthesis,brackets,colon,double quotes inside column in postgresql

None of those character require special attention:

create table t (col text);
insert into t
values ('{ [ " : ] }');

However, if you are planning to stor (valid) JSON values in that column, it's better to declare it as jsonb rather than text:

create table t (col jsonb);
insert into t
values ('{"key1": 42, "key2": [1,2,3]}');

The only character that needs special attention in string literals in SQL is the single quote - which is escaped by doubling it, e.g.: 'Arthur''s house'

Double quotes problems with Postgres

After reading few answers on Stackoverflow, I think the reason why instead of user (without quotes) a "user" table was getting created is because user is a reserved keyword in postgres and cannot be used for the table name.
Coming to the second question about the _id part:

Behind the scenes, Django appends "_id" to the field name to create
its database column name.


Related Topics



Leave a reply



Submit