what's the escape sequence for hyphen (-) in PostgreSQL
Double quotes should do it. But you'll have to always use the quoted-identifier everywhere you reference the database.
ALTER DATABASE one RENAME TO "one-two";
escape hyphen in a bash postgresql psql command line
The "quoting hell" can be somehow alleviated by providing the SQL in standard input as a here-string.
In your case I think this should do the job:
for i in db1 db2 db1-db2; do su - postgres -c "(psql <<EOF
alter database \"$i\" with connection limit = 0;
EOF
)"; done
How do I deal with SQL tablenames with hyphen (-) when writing raw queries? i.e project-users
According to http://www.postgresql.org/docs/9.0/static/sql-syntax-lexical.html, you should use double quotes.
In your case, for PostgreSQL the query should be:
SELECT * FROM "project-users";
It is good practice to avoid the use of characters that need escaping or that contain spaces in identifiers.
postgres how to refer to table names with minus signs
Use double-quotes:
select * from "v-water-a" limit 1;
Documentation: http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html
valid characters in Postgres Ltree label in utf8 charset
Sorry for not updating the answer.
Yes, i have finally figured out that it is one of our DBA that changed the source of ltree and recompile it with supporting the dash(-) char. We have a single table with more than 6B records.
PostgreSQL LIKE operator doesn't match hyphen
That pattern would not match because there is no space before [---]is Ambraam
. There is a space in your pattern, between the %
and [
characters, and it's requiring that space to be in your data. Try LIKE '%[---]is Abraam %'
.
Rails - copy a Table from one schema to another schema in same database
Need to delimit the identifier when including a dash (hyphen) in a schema or table name. Updating your query to...
"INSERT INTO \"#{app_name}.#{table}" SELECT * FROM \"#{ENV['ADMIN_TENANT']}.#{table}\";"
Should do the trick.
See... what's the escape sequence for hyphen (-) in PostgreSQL
Though it might be a better practice to just exclude the hyphen from names to begin with.
PostgreSQL - how to drop a user with hyphen in his username
Identifiers need to be quoted using double quotes, single quotes are for string literals:
DROP USER "user-name";
More details in the manual: http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
Related Topics
Parse JSON into Oracle Table Using Pl/Sql
How to Give a Unique Constraint to a Combination of Columns in Oracle
SQL Server 2005: Determine Datatype of Variable
What Are the Down Sides of Using a Composite/Compound Primary Key
Determine Row That Caused "Unexpected End of File" Error in Bulk Insert
Postgresql - Best Way to Return an Array of Key-Value Pairs
Declare Variable for a Query String
Use of Xml.Modify to Insert Parameters into Specific Element of an Xml Column
Is There a Postgres Command to List/Drop All Materialized Views
Store Multiple Elements in JSON Files in Aws Athena
Doing "Points of Interest Along a Route" in Google Maps
Combine Varchar Column with Int Column
How to Generate a Series of Hourly Averages in MySQL
Convert Access Transform/Pivot Query to SQL Server
Query Excel Worksheet in Ms-Access Vba (Using Adodb Recordset)