自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

達夢數(shù)據(jù)庫及在.Net下的增刪改查

數(shù)據(jù)庫 其他數(shù)據(jù)庫
偶然看到了國產(chǎn)數(shù)據(jù)庫——達夢數(shù)據(jù)庫。頓時起了興趣,搗鼓了一番。我們可看到對達夢數(shù)據(jù)庫進行增刪改查和操作SQLServer 差不多。要說區(qū)別,那就是多個“模式”的概念。詳細請看下文

一、簡介

 

偶然看到了國產(chǎn)數(shù)據(jù)庫——達夢數(shù)據(jù)庫。頓時起了興趣,搗鼓了一番。

 

下面這段簡介摘自百度百科

達夢數(shù)據(jù)庫是武漢華工達夢數(shù)據(jù)庫有限公司推出的具有完全自主知識產(chǎn)權(quán)的高性能數(shù)據(jù)庫產(chǎn)品。它采用“三權(quán)分立”的安全管理機制,安全級別達到B1級,并在大數(shù)據(jù)量存儲管理、并發(fā)控制、數(shù)據(jù)查詢優(yōu)化處理、事務(wù)處理、備份與恢復(fù)和支持SMP系統(tǒng)等諸多方面都有突破性進展和提高。更多介紹:http://baike.baidu.com/view/581717.htm

 

達夢數(shù)據(jù)庫有免費版和收費版(感覺國人就是有點急功近利)。

免費版下載地址:http://www.dameng.com/dmweb/article.do?type=category&articleid=57021

有Windouws版和Linux版。

 

二、安裝

 

我這里選擇Windows版下載,當(dāng)前版本6.2,UI還是做得很漂亮的。

安裝過程很簡單,一路“下一步”就行了:

2.1) 選擇語言版本

 

2.2) 選擇驗證Key文件,免費版的下載包里提供了驗證文件。

 

2.3)設(shè)置初始化參數(shù)

 

2.4)修改數(shù)據(jù)庫口令(密碼),當(dāng)然也可以無視它。默認密碼是: SYSDBA

 

 

三、使用

 

3.1) 打開管 “理工具Manager”登陸

 

輸入安裝時設(shè)置的口令,如果安裝時沒有修改口令,則輸入初試默認口令“SYSDBA”

3.2) 登陸進去后看到系統(tǒng)默認有兩個數(shù)據(jù)庫“SYSTEM”、“BOOKSHOP”。這里我自己新建了一個叫“Cnblogs”的數(shù)據(jù)庫。新建很簡單,和操作SQLServer差不多。

 

3.3) 點開“cnblogs”節(jié)點,會發(fā)現(xiàn),它不像SQLServer那樣,下面直接是“表”、“視圖”等。

它下面是“模式”,一個數(shù)據(jù)庫可以有多個模式,模式下面才會有“表”、“視圖”等等。

 

模式用來代表特定數(shù)據(jù)庫中的一個對象集,在概念上可將其看作是包含表、視圖、索引和權(quán)限定義的對象集合。一個模式只作用于一個數(shù)據(jù)庫,不同的數(shù)據(jù)庫可以有同名模式。

我在模式“SYSDBA”下面建了個“Users”表。

3.4) 達夢SQL

因為達夢數(shù)據(jù)庫有一個“模式”的概念,因此它的查詢語句和SQLServer 也有所不同,要在“表”前加上“模式”。如:

  1. select  *  from  SYSDBA.Users 

 當(dāng)然你也可以不加,直接像在SQLServer 里那樣,寫成

  1. select * from  Users  

這時它會默認使用SYSDBA模式。

四、使用C#對達夢數(shù)據(jù)庫進行CRUD操作

達夢數(shù)據(jù)庫提供了很多驅(qū)動,包括.Net 。在達夢數(shù)據(jù)的安裝目錄找到 \dmdbms\bin\ DmProvider.dll 程序集,這就是.Net 操作達夢數(shù)據(jù)庫的驅(qū)動程序。我們用VS建個Demo 引用這個dll。增刪改查的演示代碼如下:

  1. using Dm;  
  2.  
  3. /// <summary>  
  4. /// 獲得數(shù)據(jù)庫鏈接  
  5. /// </summary>  
  6. /// <returns></returns>  
  7. public DmConnection GetConn()  
  8. {  
  9.     string strconn = "server=localhost;database=Cnblogs;User Id=SYSDBA;PWD=SYSDBA";  
  10.     DmConnection conn = new DmConnection(strconn);  
  11.     conn.Open();  
  12.     return conn;  
  13. }  
  14.  
  15. //插入數(shù)據(jù)  
  16. public void Insert()  
  17. {  
  18.     DmConnection conn = GetConn();  
  19.     string strCmd = "Insert into  SYSDBA.Users(Name,Sex,Age)values('xumingxiang','man',25)";  
  20.     DmCommand cmd = new DmCommand(strCmd, conn);  
  21.     int effect = cmd.ExecuteNonQuery();  
  22.     conn.Close();//關(guān)閉數(shù)據(jù)庫鏈接  
  23. }  
  24.  
  25. /// <summary>  
  26. /// 刪除數(shù)據(jù)  
  27. /// </summary>  
  28. public void Update()  
  29. {  
  30.     DmConnection conn = GetConn();  
  31.     string strCmd = "update  SYSDBA.Users set Age=100 where Id=1";  
  32.     DmCommand cmd = new DmCommand(strCmd, conn);  
  33.     int effect = cmd.ExecuteNonQuery();  
  34.     conn.Close();  
  35. }  
  36.  
  37. /// <summary>  
  38. /// 刪除數(shù)據(jù)  
  39. /// </summary>  
  40. public void Delete()  
  41. {  
  42.     DmConnection conn = GetConn();  
  43.     string strCmd = "delete from  SYSDBA.Users  where Id=1";  
  44.     DmCommand cmd = new DmCommand(strCmd, conn);  
  45.     int effect = cmd.ExecuteNonQuery();  
  46.     conn.Close();  
  47. }  
  48.  
  49. /// <summary>  
  50. /// 用ExecuteReader查詢數(shù)據(jù)  
  51. /// </summary>  
  52. public void QueryByExecuteReader()  
  53. {  
  54.     DmConnection conn = GetConn();  
  55.     string strCmd = "select * from  SYSDBA.Users ";  
  56.     DmCommand cmd = new DmCommand(strCmd, conn);  
  57.     DmDataReader dr = cmd.ExecuteReader();  
  58.  
  59.     int id;  
  60.     string name;  
  61.     string sex;  
  62.     int age;  
  63.     while (dr.Read())  
  64.     {  
  65.         id = dr.GetInt32(0);  
  66.         name = dr.GetString(1);  
  67.         sex = dr.GetString(2);  
  68.         age = dr.GetInt32(3);  
  69.     }  
  70. }  
  71.  
  72.  
  73. /// <summary>  
  74. ///用DataAdapter 查詢數(shù)據(jù),返回DataSet  
  75. /// </summary>  
  76. public DataSet QueryByDataAdapter()  
  77. {  
  78.     DmConnection conn = GetConn();  
  79.     string strCmd = "select * from  SYSDBA.Users ";  
  80.     DmDataAdapter da = new DmDataAdapter(strCmd,conn);  
  81.     DataSet ds = new DataSet();  
  82.     da.Fill(ds);  
  83.     return ds;  

在上面的代碼中,我們可看到對達夢數(shù)據(jù)庫進行增刪改查和操作SQLServer 差不多。要說區(qū)別,那就是多個“模式”的概念。

 

由于只是興趣使然,只是簡單的嘗嘗鮮,我沒有對其性能、負載等方面做測試,也沒打算用它做實際項目。等以后有空了在繼續(xù)搗鼓它吧。不說他好也不說他壞,在精神上支持一下國貨吧!

原文地址:http://www.cnblogs.com/xumingxiang/archive/2012/04/11/2442271.html

【編輯推薦】

  1. 11個重要的數(shù)據(jù)庫設(shè)計規(guī)則
  2. 讓數(shù)據(jù)庫變快的10個建議
  3. 20個數(shù)據(jù)庫設(shè)計***實踐
  4. 超越MySQL 對流行數(shù)據(jù)庫進行分支
  5. 2012,國產(chǎn)數(shù)據(jù)庫將迎發(fā)展春天
責(zé)任編輯:林師授 來源: 徐明祥的博客
相關(guān)推薦

2009-11-13 15:54:26

ADO.NET數(shù)據(jù)庫操

2019-11-07 15:39:36

數(shù)據(jù)庫MySQL文章

2010-07-28 13:47:32

達夢數(shù)據(jù)庫

2021-10-20 09:04:21

Spring Beanscope數(shù)據(jù)庫

2014-04-16 14:36:03

2012-05-18 14:19:08

達夢DM7.0海量數(shù)據(jù)

2011-09-02 14:18:53

OracleBULK COLLECFORALL

2013-03-25 10:26:19

XML數(shù)據(jù)庫

2020-12-11 16:37:46

數(shù)據(jù)庫/新基建/全棧

2025-03-11 07:31:04

2012-04-19 10:06:16

ibmdw

2010-06-11 13:22:32

2010-06-10 10:57:57

2023-02-27 07:37:56

Curl操作SQL

2024-08-29 08:58:30

JPA編寫數(shù)據(jù)操

2010-05-13 14:27:52

訪問MySQL

2014-08-04 10:46:46

達夢數(shù)據(jù)庫

2014-03-07 14:11:34

達夢數(shù)據(jù)庫EAL4安全認證

2023-06-08 08:13:43

2014-05-12 10:17:14

達夢數(shù)據(jù)庫微軟
點贊
收藏

51CTO技術(shù)棧公眾號