user1243746
user1243746

Reputation:

Should be quoted the names in SQL?

At creating tables and initial data, should be quoted all table names and column names by default?

i.e., for MySQL:

CREATE TABLE `address` (`address_id` INT PRIMARY KEY, `street` TEXT);

vs

CREATE TABLE address (address_id INT PRIMARY KEY, street TEXT);

Upvotes: 1

Views: 64

Answers (1)

John Woo
John Woo

Reputation: 263713

No (it is optional in your case), only escape the column names which has space in between or the name you are using is a MySQL Reserved Word.

Example

CREATE TABLE `ADD`
(
    `CASE` VARCHAR(50),
    `FROM` DATETIME,
    `TO` DATETIME,
    `Person Name` VRCHAR(50)
);

Upvotes: 4

Related Questions