Does MySQL allows to create database with dot?

前端 未结 4 1270
南笙
南笙 2020-11-30 09:48

Does MySQL allows to create database which has dot (.) in its name?

I\'m using MySQL 5.1.22.

4条回答
  •  暖寄归人
    2020-11-30 10:14

    You can't use the dot in a database name. Also, I'd avoid using it in any identifier. A common convention is to use underscore instead. It will serve the same purpose and will avoid a LOT of confusion. If you do have a good reason for using strange and otherwise-illegal characters in a table or field name, then you have to escape it.

    to escape identifiers in MySQL, use the backtick:

    SELECT `select`, `some.field name`, `crazy()naming+here`
    FROM `my-=+table`
    

    Getting into the habit of backticking all field names regardless of whether you need to is a good practice in my opinion, but that's another story.

提交回复
热议问题