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.字串的模式比對, Regex:
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 |
+-------+--------+---------+------+------------+-------+
Regex: 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`