For example, mysql quote table name using
SELECT * FROM `table_name`;
notice the `
Does other database ever use different char to quote their table name
Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database. Stick to using single quotes. That's the primary use anyway.
SQL requires single quotes around text values (most database systems will also allow double quotes).
QUOTE() : This function in MySQL is used to return a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotation marks and with each instance of backslash (\), single quote ('), ASCII NULL, and Control+Z preceded by a backslash.
Double quotes are used to indicate identifiers within the database, which are objects like tables, column names, and roles. In contrast, single quotes are used to indicate string literals.
This use of quotes is called delimited identifiers. It's an important part of SQL because otherwise you can't use identifiers (e.g. table names and column names) that:
The standard SQL language uses double-quotes for delimited identifiers:
SELECT * FROM "my table";
MySQL uses back-quotes by default. MySQL can use standard double-quotes:
SELECT * FROM `my table`; SET SQL_MODE=ANSI_QUOTES; SELECT * FROM "my table";
Microsoft SQL Server and Sybase uses brackets by default. They can both use standard double-quotes this way:
SELECT * FROM [my table]; SET QUOTED_IDENTIFIER ON; SELECT * FROM "my table";
InterBase and Firebird need to set the SQL dialect to 3 to support delimited identifiers.
Most other brands of database use double-quotes correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With