在MySQL中可以使用下划线作为表名吗?
是的,我们可以在表名周围使用反引号将下划线添加为表名。以下是语法-
INSERT INTO `yourTableName` values(yourValue1,.......N);
让我们首先创建一个表-
mysql> create table `DemoTable_1` ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Location varchar(100) );
使用插入命令在表中插入一些记录-
mysql> insert into `DemoTable_1`(Location) values('C:/myFolder/JavaFiles'); mysql> insert into `DemoTable_1`(Location) values('E:/AllJarOfJava'); mysql> insert into `DemoTable_1`(Location) values('C:/ProgramFiles');
使用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)