Selecting a database in mysql with spaces in its name

前端 未结 6 1439
抹茶落季
抹茶落季 2020-12-10 12:10

I want to select my particular database in mysql console, but the problem is that my database name has a space in between and mysql ignores the part after the space. For ins

相关标签:
6条回答
  • 2020-12-10 12:53

    You have to use square brackets to get this work:

    Use [student registration]
    
    0 讨论(0)
  • 2020-12-10 12:59

    Use student registration without quotes.

    0 讨论(0)
  • 2020-12-10 13:04

    You should try using back ticks ("`") to quote your database name. Generally speaking, it's probably better to use a naming convention to eliminate white space, e.g.

    USE `StudentRegistration`;
    

    or

    USE `student_registration`;
    
    0 讨论(0)
  • 2020-12-10 13:05

    Use Double quotes instead of single, double quotes worked for me :

    USE "student registration";
    
    0 讨论(0)
  • 2020-12-10 13:13

    You have two options.

    1 Enclose the database name in backticks or single quotes.

    USE `student registration`;
    USE 'student registration';
    

    2 Escape the white space character.

    USE student\ registration;

    Oddly enough this produces.

    ERROR: Unknown command '\ '.

    But still changes the database.

    0 讨论(0)
  • 2020-12-10 13:14

    When I had to deal with other people's tables with spaces the following worked:

    use `student registration`;
    

    At least that would be yours.

    0 讨论(0)
提交回复
热议问题