I need to know whether any database supports double quotes as a part of their table name. I am especially interested in JDBC compliant databases. And if they do, can I please know how?

  • 3
    Why on earth would you ever want to do that? – a_horse_with_no_name Feb 14 '19 at 11:34
  • Double-quote char have special meaning, so when you want to use it as a common char you must quote it. The quoting method is dependent by DBMS. It can be quoting by slash or another symbol, doubling, wrapping... Of course, some DBMSs may not allow that at all. – Akina Feb 14 '19 at 11:45

According to the SQL standard, this should be possible by doubling the double quotes (similar to escaping single quotes in string constants).

At least Postgres does support this (and Oracle does not, resulting in "ORA-03001: unimplemented feature")

create table "really""stupid_name"(id integer);

Online example: https://rextester.com/JYCW13692

However, using quoted identifiers is a bad idea to begin with. Let alone identifiers that in turn contain double quotes.

I would strongly suggest you do not do this.

  • SQL Server and MySQL also support this nonsense! SQL Server fiddle, MySQL fiddle – ypercubeᵀᴹ Feb 14 '19 at 11:48
  • But SQLite is awesome – ypercubeᵀᴹ Feb 14 '19 at 12:05
  • 2
    @ypercubeᵀᴹ: actually I find it quite sad, that SQLite gives in and accepts all non-standard identifier types when the rules for SQL identifiers have been laid out more than 30 years ago - pre dating all those DBMS that chose to ignore that. – a_horse_with_no_name Feb 14 '19 at 12:15
  • Yeah. SQLite and MySQL especially have a very weird approach to handling string literals and identifiers (essentially allowing them to being mixed up freely in almost all cases). – ypercubeᵀᴹ Feb 14 '19 at 12:35
Server version: 8.0.12 MySQL Community Server - GPL
mysql> CREATE TABLE `test"d"quote` (id int);
Query OK, 0 rows affected (0.31 sec)

mysql> insert into `test"d"quote` values (1), (11);
Query OK, 2 rows affected (0.11 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from `test"d"quote`;
| id   |
|    1 |
|   11 |
2 rows in set (0.00 sec)

mysql> drop table `test"d"quote`;
Query OK, 0 rows affected (0.22 sec)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.