Drop database with special characters - sql

While testing RoR, I created a database that is literally named "<test_project>_development", so when I try to drop it through postgresql I get a syntax error because of the "<>" in the database's name.

Postgres uses quotes to delimit literal entity names:
drop database "<test_project>_development"
See documentation.

Related

Create mixed case table name/columns in oracle WITHOUT using quotes

Is there any way I can create a mixed case table name in Oracle without using quotes?
The table names change to uppercase if I do not use quotes while creating the table.
Let me know if you need more information.
Eg:
create table testTable(testColumn varchar);
This creates a table named TESTTABLE with column name TESTCOLUMN.
I can use quotes, but it makes it more messy and difficult to write queries.
Can you please let me know how I can do this without using quotes? Thanks.
Regards,
Sawan
Please refer to the official Oracle Database documentation:
"Nonquoted identifiers are not case sensitive. Oracle interprets them as uppercase."
https://docs.oracle.com/en/database/oracle/oracle-database/20/sqlrf/Database-Object-Names-and-Qualifiers.html#GUID-3C59E44A-5140-4BCA-B9E1-3039C8050C49
All the data dictionary views will show the identifiers as Oracle interprets them. In other words, without quotes everything will be uppercase. I can testify that this is true even for accented characters.
You can't always get what you want...

Escape table name in SQLite?

I have table named References in SQLite, so I can't target it, it seems. SQLite studio I use to edit databases throws an error.
Is there a way to escape database name?
The query is:
UPDATE References
SET DateTimeLastEdited = datetime('now', 'localtime')
WHERE NewsItemID = old.NewsItemID;
(This is part of the trigger I am making.)
You can escape table names with double quotes:
UPDATE "References" SET DateTimeLastEdited = datetime('now', 'localtime') WHERE NewsItemID = old.NewsItemID;
Depending on what you want to escape, you need to use different delimiters:
If you want to use a keyword as a name, you need to quote it. There
are four ways of quoting keywords in SQLite:
'keyword' A keyword in single quotes is a string literal.
"keyword" A keyword in double-quotes is an identifier.
[keyword] A
keyword enclosed in square brackets is an identifier. This is not
standard SQL. This quoting mechanism is used by MS Access and SQL
Server and is included in SQLite for compatibility.
`keyword` A
keyword enclosed in grave accents (ASCII code 96) is an identifier.
This is not standard SQL. This quoting mechanism is used by MySQL and
is included in SQLite for compatibility.
From SQLite documentation

Sqlite Parameterized insert query (escape)

Hi I try to use SQLite Parameterized query
but in the column name is a DOT (.)
INSERT INTO Data (`test.1`, `test.2`, `test.3`) VALUES (#test.1, #test.3,#test.3)
Returns
"SQL logic error or missing database near ".": syntax error"
INSERT INTO Data (`test.1`, `test.2`, `test.3`) VALUES ([#test.1], [#test.3],[#test.3])
Returns
"SQL logic error or missing database
no such column: #test.1"
how can i escape the dot and still use the names as parameters!?
The "proper" escape character in SQLite is double quotes:
INSERT INTO Data("test.1", "test.2", "Test.3")
VALUES ([#test1], [#test3], [#test3])
Leave the . out of the parameter name -- presumably, you have control over that.
SQLite explicitly supports the backtick for compatibility with MySQL and the square braces for compatibility with MS Access and SQL Server. (As you can see in the documentation.)

How to configure PL/SQL Developer IDE to leave the columns names as they are?

I have created a table with some columns using PL/SQL Develper to access this Oracle database.
After clicking the "Apply" button that will create the table, all my column names suddenly become upper case (which can hardly be read), including the table name!
Would that be possible to configure PL/SQL Developer IDE to leave the columns names and table names as they are?!
Oracle DBMS ignores case and translates everything to uppercase unless you use quotes. But the quotes have the liability that you always have to use them.
If you do not use the quotes you will get an error message ORA-00942: table or view does not exist
You can give column name in double quote "". Then those column name will be in as it is.

What is wrong with this SQL syntax?

UPDATE files
SET filepath = REPLACE(filepath, `sites/somedomain.com/files/`, `sites/someotherdomain.com/files/`);
I have a table called files with a field called filepath. MySQL returns this error: Unknown column 'sites/somedomain.com/files/' in 'field list'
Use normal quotes instead of backquotes: normal quotes identify strings, backquotes identify column names.
To expand on kemp's answer:
Backquotes or backticks ` are used in MySQL to enclose the names of schema objects (databases, tables, columns, indexes, procedures, ...). They cannot be used to enclose strings. You must use regular single- or double-quotes: ' or " for that.
+1 to answers given by #kemp and #Hammerite.
See also my answer to this question: Do different databases use different name quote?