rI> select ,This \tis \tfour\tlines'; ●000 521常m his is four ones MySQL This is lines H ow in set (0.00 sec) 【例5.1】执行如 ysql> select This \bis four\blin Thiifoulines i select'This\ Thiifoulines row in set (g g0 sec) ysql> select This \P\is\r\four\Nlines; 执行结果为 This Ines This row in set (0.00 sec> gl> select 'ThisNisNnfourNnlines': This anes MySQL数据库应用》ht 第21页 set (o.00 sec)
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 21 页 5.2.1 常量 【例5.1】执行如下语句: select 'This\nis\nfour\nlines ' ; 执行结果为: “\n”表示回车
521常量 MySQL ●000 在字符串中包括引号,有以下几种方式 字符串用单引号“: 字符串内引用的单引号“’”,可以写成“’’”(两个单引号) 字符串内引用的双引号“””,不需要特殊处理。 字符串用双引号“"": 字符串内引用的双引号“””,可以写成“”””(两个双引号); 字符串内引用的单引号“’”不需要特殊处理; 可以在引号前加转义字符(“"),例如\“或者\。 MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第22页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 22 页 5.2.1 常量 在字符串中包括引号,有以下几种方式: – 字符串用单引号“'”: 字符串内引用的单引号“’” ,可以写成“’’”(两个单引号); 字符串内引用的双引号“”” ,不需要特殊处理。 – 字符串用双引号“"”: 字符串内引用的双引号“”” ,可以写成“”””(两个双引号); 字符串内引用的单引号“’”不需要特殊处理; – 可以在引号前加转义字符(“\” ),例如 \“ 或者 \’
521常量 MySQL ●000 执行下面的语句 select hello hello hel'lo,he II 执行结果为 nysq1〉 select'helo’,'"he1lo",'""he1lo",‘he11o,,'\he11o’; he llo he llo he llo i he he llo he llo i he llo'i he llo"i hehe llo i row in set (0.01 sec) MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第23页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 23 页 select 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello'; 5.2.1 常量 执行下面的语句: 执行结果为:
521常量 MySQL ●000 执行下面的语句 select heIIo select he"Ilo se lect heo select heRo mysql> select "he1lo"; he’111o 执行结果为 hello H 1 row in set (0.00 sec) MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第24页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 24 页 5.2.1 常量 执行下面的语句: select 'he ''llo ' ; select 'he "llo ' ; select "he ""llo " ; select "he ''llo " ; 执行结果为:
521常量 MySQL ●000 (2)数值常量 数值常量可以分为整数常量和浮点数常量。 整数常量:即不带小数点的十进制数。 例如:1894,2,+145345234,-2147483648。 浮点数常量:是使用小数点的数值常量。 例如:5.26,-1.39,101.5E5,0.5E-2。 MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第25页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 25 页 5.2.1 常量 (2)数值常量 数值常量可以分为整数常量和浮点数常量。 – 整数常量:即不带小数点的十进制数。 例如:1894,2, +145345234,–2147483648。 – 浮点数常量:是使用小数点的数值常量。 例如:5.26,1.39,101.5E5,0.5E2