可以在 MySQL 中把下划线用作表名吗?
可以,我们可以用反引号将表名括起来,在表名中添加下划线。以下为语法:-
INSERT INTO `yourTableName` values(yourValue1,.......N);
我们先创建一个表:-
mysql> create table `DemoTable_1` ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Location varchar(100) ); Query OK, 0 rows affected (1.17 sec)
使用插入命令在表中插入一些记录:-
mysql> insert into `DemoTable_1`(Location) values('C:/myFolder/JavaFiles'); Query OK, 1 row affected (0.20 sec) mysql> insert into `DemoTable_1`(Location) values('E:/AllJarOfJava'); Query OK, 1 row affected (0.17 sec) mysql> insert into `DemoTable_1`(Location) values('C:/ProgramFiles'); Query OK, 1 row affected (0.17 sec)
使用 select 语句显示表中的所有记录:-
mysql> select *from `DemoTable_1`;
这将产生以下输出:-
+----+-----------------------+ | Id | Location | +----+-----------------------+ | 1 | C:/myFolder/JavaFiles | | 2 | E:/AllJarOfJava | | 3 | C:/ProgramFiles | +----+-----------------------+ 3 rows in set (0.00 sec)
广告