MySQL 通過 C#訪問的一些問題

來源:互聯網
上載者:User

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`

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.