Selecting a database in mysql with spaces in its name

≡放荡痞女 提交于 2019-11-26 17:49:05

问题


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 instance, when i give the command:

use 'student registration'

I get the message:

cannot find database 'student'

回答1:


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`;



回答2:


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.




回答3:


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

use `student registration`;

At least that would be yours.




回答4:


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

USE "student registration";



回答5:


You have to use square brackets to get this work:

Use [student registration]



回答6:


Use student registration without quotes.



来源:https://stackoverflow.com/questions/506826/selecting-a-database-in-mysql-with-spaces-in-its-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!