MySQL 通过 C#访问的一些问题
1. MySQL 中不使用 单引号 , 而是用 ` ( 就是键盘左上角的那个~) , 这个不是单引号 '
2. drop schema , drop schema
3. 枚举表
string MyConString = "SERVER=localhost;" +
"DATABASE=information_schema;" +
"UID=root;" +
"PASSWORD=password;";
var strSelect = @"select * from information_schema.tables where left(TABLE_SCHEMA,6)='galaxy'";
4.字符串的模式匹配, 正则表达式:
select * from information_schema.tables where left(TABLE_SCHEMA,6)='galaxy'
select * from information_schema.tables where TABLE_SCHEMA REGEXP 'galaxy_ks_v6_s_[[:digit:]]+'
要想找出包含“w”的名字:
mysql> SELECT * FROM pet WHERE name LIKE '%w%';
+----------+-------+---------+------+------------+------------+
| name | owner | species | sex | birth | death |
+----------+-------+---------+------+------------+------------+
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
+----------+-------+---------+------+------------+------------+
要想找出正好包含5个字符的名字,使用“_”模式字符:
mysql> SELECT * FROM pet WHERE name LIKE '_____';
+-------+--------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+-------+--------+---------+------+------------+-------+
| Claws | Gwen | cat | m | 1994-03-17 | NULL |
| Buffy | Harold | dog | f | 1989-05-13 | NULL |
+-------+--------+---------+------+------------+-------+
正则表达式: http://dev.mysql.com/doc/refman/5.1/zh/regexp.html
模式匹配: http://dev.mysql.com/doc/refman/5.1/zh/tutorial.html#pattern-matching
5. 枚举DatabaseName
SELECT `SCHEMA_NAME` FROM `information_schema`.`SCHEMATA`