Can we have the table name as “option” in MySQL?

后端 未结 8 1169
挽巷
挽巷 2020-12-19 01:41

I am very, very new to MYSQL.I tried to create a table named \"option\". My SQL Query is :

create table option(

id int not

相关标签:
8条回答
  • 2020-12-19 01:44

    If you want to have a table name Option, you should be able to, just remember that whenever you use the table in a query, you will have to encase it in ` symbols. Like this.

    `option`
    

    The ` key on the top left of your keyboard, with the tilde.

    0 讨论(0)
  • 2020-12-19 01:48

    Pick a different name (one that isn't a reserved word in your RDBMS) and save yourself and whoever else might work on it many headaches.

    0 讨论(0)
  • 2020-12-19 01:48

    You can use SQL keywords as table names in MySQL if you escape them with back-quotes.

     CREATE TABLE `option` (
         ...
     )
    

    It's not normally a good idea to do so, though.

    0 讨论(0)
  • 2020-12-19 01:52

    option is a reserved word in Mysql.we can use a reserved word by using the word inside a single quotes.

    0 讨论(0)
  • 2020-12-19 01:53

    Yes you can definitely create a table named option but in every query you will have to use

    `option`
    

    instead of plain option. Better improvise a little and create a table named options to save from trouble. Restrain from using mysql reserved words as table name or column name or procedure names.

    0 讨论(0)
  • 2020-12-19 01:56

    See the MySQL documentation on this. You can do it as follows:

    create table `option` (
    ...
    )
    
    0 讨论(0)
提交回复
热议问题