要在MySQL中設(shè)置列名中的空格,可以使用反引號(hào)的概念。讓我們首先創(chuàng)建一個(gè)表。以下是查詢的語(yǔ)句 ?
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)
登錄后復(fù)制
以下是使用插入命令在表中插入一些記錄的查詢 –
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)
登錄后復(fù)制
以下是使用select語(yǔ)句顯示表中所有記錄的查詢:
mysql> select `Student Id`,`Student Full Name` from blankSpacesDemo;
登錄后復(fù)制
以下是在列名稱“學(xué)生全名”中顯示空格的輸出 –
+------------+--------------------+ | Student Id | Student Full Name | +------------+--------------------+ | 1 | John Smith | | 2 | Carol Taylor | | 3 | David Miller | +------------+--------------------+ 3 rows in set (0.00 sec)
登錄后復(fù)制
以上就是使用 MySQL 設(shè)置列名中的空格?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!