登录
首页 >  数据库 >  MySQL

使用 MySQL 设置列名中的空格?

来源:tutorialspoint

时间:2023-09-06 10:58:09 227浏览 收藏

在IT行业这个发展更新速度很快的行业,只有不停止的学习,才不会被行业所淘汰。如果你是数据库学习者,那么本文《使用 MySQL 设置列名中的空格?》就很适合你!本篇内容主要包括##content_title##,希望对大家的知识积累有所帮助,助力实战开发!

要在MySQL中设置列名中的空格,可以使用反引号的概念。让我们首先创建一个表。以下是查询的语句 −

mysql> create table blankSpacesDemo
   -> (
   -> `Student Id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> `Student Full Name` varchar(100)
   -> );
Query OK, 0 rows affected (0.51 sec)

以下是使用插入命令在表中插入一些记录的查询 -

mysql> insert into blankSpacesDemo(`Student Full Name`) values('John Smith');
Query OK, 1 row affected (0.16 sec)

mysql> insert into blankSpacesDemo(`Student Full Name`) values('Carol Taylor');
Query OK, 1 row affected (0.14 sec)

mysql> insert into blankSpacesDemo(`Student Full Name`) values('David Miller');
Query OK, 1 row affected (0.15 sec)

以下是使用select语句显示表中所有记录的查询:

mysql> select `Student Id`,`Student Full Name` from blankSpacesDemo;

以下是在列名称“学生全名”中显示空格的输出 -

+------------+--------------------+
| Student Id | Student Full Name  |
+------------+--------------------+
| 1          | John Smith         |
| 2          | Carol Taylor       |
| 3          | David Miller       |
+------------+--------------------+
3 rows in set (0.00 sec)

到这里,我们也就讲完了《使用 MySQL 设置列名中的空格?》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:tutorialspoint 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>