Hi @acurus, When dealing with table names containing special characters, such as the hyphen (“-”), you can use square brackets to enclose the table name. This approach is commonly used in SQL databases to handle irregular identifiers.
Here are some ways to work with table names that include special characters:
Using Square Brackets:
- Enclose the table name in square brackets, like this:CREATE TABLE [Table-One] (ID INT NOT NULL);
- Similarly, when querying the table, use:SELECT * FROM [Table-One];
- Note that while this approach works, it’s considered a best practice to avoid using special characters in table names whenever possible.
Double Quotes (For Oracle):
- In Oracle databases, you can use double quotes to create a table with special characters:CREATE TABLE "Table-With-Special-Character" (ID INT NOT NULL);
- When querying the table, use:SELECT * FROM "Table-With-Special-Character";
- Remember that this method is case-sensitive, so ensure the table name matches exactly.
Escape Characters:
- You can use the ESCAPE keyword to search for specific characters within column values. For example:SELECT * FROM TestTable WHERE Col1 LIKE '%! [blog.]%' ESCAPE '!'; Replace the exclamation mark (“!”) with any other special character you want to search for.
Remember that while these techniques allow you to work with tables containing special characters, it’s generally recommended to avoid using irregular identifiers to maintain code readability and compatibility across different database clients.
If possible, consider renaming the table to a more standard format without special characters.