目录:

一、新建项目,添加引用

二、创建数据库

三、创建表

四、插入数据 

五、查询数据 

六、删除数据 

七、运算符

八、like语句


我的环境配置:windows 64,VS,SQLite(点击下载),System.Data.SQLite.DLL(点击下载)。

一、新建项目,添加引用

1.在VS中新建一个控制台应用程序,如下图

2.添加引用

将下载的System.Data.SQLite.DLL复制到新建项目的路径下

在VS中找到项目,右键选择添加引用

浏览到dll路径下,添加进来。

代码中添加

  1. using System.Data.SQLite;

添加类库CSQLiteHelper,用于存放SQLite操作方法(此代码原文链接. https://blog.csdn.net/pukuimin1226/article/details/8516733

具体代码

  1. 1 using System;
  2. 2 using System.Collections.Generic;
  3. 3 using System.Linq;
  4. 4 using System.Text;
  5. 5 using System.Data.SQLite;
  6. 6 using System.Data;
  7. 7 using System.Xml;
  8. 8 using System.Text.RegularExpressions;
  9. 9 using System.IO;
  10. 10
  11. 11 namespace CSharp_SQLite
  12. 12 {
  13. 13 public class CSQLiteHelper
  14. 14 {
  15. 15 private string _dbName = "";
  16. 16 private SQLiteConnection _SQLiteConn = null; //连接对象
  17. 17 private SQLiteTransaction _SQLiteTrans = null; //事务对象
  18. 18 private bool _IsRunTrans = false; //事务运行标识
  19. 19 private string _SQLiteConnString = null; //连接字符串
  20. 20 private bool _AutoCommit = false; //事务自动提交标识
  21. 21
  22. 22 public string SQLiteConnString
  23. 23 {
  24. 24 set { this._SQLiteConnString = value; }
  25. 25 get { return this._SQLiteConnString; }
  26. 26 }
  27. 27
  28. 28 public CSQLiteHelper(string dbPath)
  29. 29 {
  30. 30 this._dbName = dbPath;
  31. 31 this._SQLiteConnString = "Data Source=" + dbPath;
  32. 32 }
  33. 33
  34. 34 /// <summary>
  35. 35 /// 新建数据库文件
  36. 36 /// </summary>
  37. 37 /// <param name="dbPath">数据库文件路径及名称</param>
  38. 38 /// <returns>新建成功,返回true,否则返回false</returns>
  39. 39 static public Boolean NewDbFile(string dbPath)
  40. 40 {
  41. 41 try
  42. 42 {
  43. 43 SQLiteConnection.CreateFile(dbPath);
  44. 44 return true;
  45. 45 }
  46. 46 catch (Exception ex)
  47. 47 {
  48. 48 throw new Exception("新建数据库文件" + dbPath + "失败:" + ex.Message);
  49. 49 }
  50. 50 }
  51. 51
  52. 52
  53. 53 /// <summary>
  54. 54 /// 创建表
  55. 55 /// </summary>
  56. 56 /// <param name="dbPath">指定数据库文件</param>
  57. 57 /// <param name="tableName">表名称</param>
  58. 58 static public void NewTable(string dbPath, string tableName)
  59. 59 {
  60. 60
  61. 61 SQLiteConnection sqliteConn = new SQLiteConnection("data source=" + dbPath);
  62. 62 if (sqliteConn.State != System.Data.ConnectionState.Open)
  63. 63 {
  64. 64 sqliteConn.Open();
  65. 65 SQLiteCommand cmd = new SQLiteCommand();
  66. 66 cmd.Connection = sqliteConn;
  67. 67 cmd.CommandText = "CREATE TABLE " + tableName + "(Name varchar,Team varchar, Number varchar)";
  68. 68 cmd.ExecuteNonQuery();
  69. 69 }
  70. 70 sqliteConn.Close();
  71. 71 }
  72. 72 /// <summary>
  73. 73 /// 打开当前数据库的连接
  74. 74 /// </summary>
  75. 75 /// <returns></returns>
  76. 76 public Boolean OpenDb()
  77. 77 {
  78. 78 try
  79. 79 {
  80. 80 this._SQLiteConn = new SQLiteConnection(this._SQLiteConnString);
  81. 81 this._SQLiteConn.Open();
  82. 82 return true;
  83. 83 }
  84. 84 catch (Exception ex)
  85. 85 {
  86. 86 throw new Exception("打开数据库:" + _dbName + "的连接失败:" + ex.Message);
  87. 87 }
  88. 88 }
  89. 89
  90. 90 /// <summary>
  91. 91 /// 打开指定数据库的连接
  92. 92 /// </summary>
  93. 93 /// <param name="dbPath">数据库路径</param>
  94. 94 /// <returns></returns>
  95. 95 public Boolean OpenDb(string dbPath)
  96. 96 {
  97. 97 try
  98. 98 {
  99. 99 string sqliteConnString = "Data Source=" + dbPath;
  100. 100
  101. 101 this._SQLiteConn = new SQLiteConnection(sqliteConnString);
  102. 102 this._dbName = dbPath;
  103. 103 this._SQLiteConnString = sqliteConnString;
  104. 104 this._SQLiteConn.Open();
  105. 105 return true;
  106. 106 }
  107. 107 catch (Exception ex)
  108. 108 {
  109. 109 throw new Exception("打开数据库:" + dbPath + "的连接失败:" + ex.Message);
  110. 110 }
  111. 111 }
  112. 112
  113. 113 /// <summary>
  114. 114 /// 关闭数据库连接
  115. 115 /// </summary>
  116. 116 public void CloseDb()
  117. 117 {
  118. 118 if (this._SQLiteConn != null && this._SQLiteConn.State != ConnectionState.Closed)
  119. 119 {
  120. 120 if (this._IsRunTrans && this._AutoCommit)
  121. 121 {
  122. 122 this.Commit();
  123. 123 }
  124. 124 this._SQLiteConn.Close();
  125. 125 this._SQLiteConn = null;
  126. 126 }
  127. 127 }
  128. 128
  129. 129 /// <summary>
  130. 130 /// 开始数据库事务
  131. 131 /// </summary>
  132. 132 public void BeginTransaction()
  133. 133 {
  134. 134 this._SQLiteConn.BeginTransaction();
  135. 135 this._IsRunTrans = true;
  136. 136 }
  137. 137
  138. 138 /// <summary>
  139. 139 /// 开始数据库事务
  140. 140 /// </summary>
  141. 141 /// <param name="isoLevel">事务锁级别</param>
  142. 142 public void BeginTransaction(IsolationLevel isoLevel)
  143. 143 {
  144. 144 this._SQLiteConn.BeginTransaction(isoLevel);
  145. 145 this._IsRunTrans = true;
  146. 146 }
  147. 147
  148. 148 /// <summary>
  149. 149 /// 提交当前挂起的事务
  150. 150 /// </summary>
  151. 151 public void Commit()
  152. 152 {
  153. 153 if (this._IsRunTrans)
  154. 154 {
  155. 155 this._SQLiteTrans.Commit();
  156. 156 this._IsRunTrans = false;
  157. 157 }
  158. 158 }
  159. 159
  160. 160
  161. 161 }
  162. 162 }

此时运行会报错,

警告  所生成项目的处理器架构“MSIL”与引用“System.Data.SQLite”的处理器架构“x86”不匹配。这种不匹配可能会导致运行时失败。请考虑通过配置管理器更改您的项目的目标处理器架构,以使您的项目与引用间的处理器架构保持一致,或者为引用关联一个与您的项目的目标处理器架构相符的处理器架构。

修改项目属性:x86。

再次运行,无误。


 二、创建数据库

SQLite 是文件型的数据库,后缀名可以是".db3"、".db"或者“.sqlite”,甚至可以由你决定它的后缀。其中前3个类型是SQLite默认类型。

新建一个数据库文件,代码如下

  1. 1 /// <summary>
  2. 2 /// 新建数据库文件
  3. 3 /// </summary>
  4. 4 /// <param name="dbPath">数据库文件路径及名称</param>
  5. 5 /// <returns>新建成功,返回true,否则返回false</returns>
  6. 6 static public Boolean NewDbFile(string dbPath)
  7. 7 {
  8. 8 try
  9. 9 {
  10. 10 SQLiteConnection.CreateFile(dbPath);
  11. 11 return true;
  12. 12 }
  13. 13 catch (Exception ex)
  14. 14 {
  15. 15 throw new Exception("新建数据库文件" + dbPath + "失败:" + ex.Message);
  16. 16 }
  17. 17 }

三、创建表

  1. 1 /// <summary>
  2. 2 /// 创建表
  3. 3 /// </summary>
  4. 4 /// <param name="dbPath">指定数据库文件</param>
  5. 5 /// <param name="tableName">表名称</param>
  6. 6 static public void NewTable(string dbPath, string tableName)
  7. 7 {
  8. 8
  9. 9 SQLiteConnection sqliteConn = new SQLiteConnection("data source=" + dbPath);
  10. 10 if (sqliteConn.State != System.Data.ConnectionState.Open)
  11. 11 {
  12. 12 sqliteConn.Open();
  13. 13 SQLiteCommand cmd = new SQLiteCommand();
  14. 14 cmd.Connection = sqliteConn;
  15. 15 cmd.CommandText = "CREATE TABLE " + tableName + "(Name varchar,Team varchar, Number varchar)";
  16. 16 cmd.ExecuteNonQuery();
  17. 17 }
  18. 18 sqliteConn.Close();
  19. 19 }

例子:创建一个数据库文件  NBA.db3

然后创建表Stars,再创建表的列,Name,Team,Number。

  1. 1 class Program
  2. 2 {
  3. 3 private static string dbPath = @"d:\NBA.db3";
  4. 4 static void Main(string[] args)
  5. 5 {
  6. 6 //创建一个数据库db文件
  7. 7 CSQLiteHelper.NewDbFile(dbPath);
  8. 8 //创建一个表
  9. 9 string tableName = "Stars";
  10. 10 CSQLiteHelper.NewTable(dbPath, tableName);
  11. 11 }
  12. 12 }

看下效果,数据库文件NBA的表Stars中有Name,Team和Number字段


四、插入数据

接下来,使用SQLite 的 INSERT INTO 语句用于向数据库的某个表中添加新的数据行。

先在Main()方法中创建一些数据。

  1. 1 List<object[]> starsDatas = new List<object[]>();
  2. 2 starsDatas.Add(new object[] { "Garnett", "Timberwolves", "21" });
  3. 3 starsDatas.Add(new object[] { "Jordan", "Bulls", "23" });
  4. 4 starsDatas.Add(new object[] { "Kobe", "Lakers", "24" });
  5. 5 starsDatas.Add(new object[] { "James", "Cavaliers", "23" });
  6. 6 starsDatas.Add(new object[] { "Tracy", "Rockets", "1" });
  7. 7 starsDatas.Add(new object[] { "Carter", "Nets", "15" });

将数据插入到表单中

  1. 1 private static void AddStars(List<object[]> stars)
  2. 2 {
  3. 3 CSQLiteHelper sqlHelper = new CSQLiteHelper(dbPath);
  4. 4 sqlHelper.OpenDbConn();
  5. 5 string commandStr = "insert into Stars(Name,Team,Number) values(@name,@team,@number)";
  6. 6 foreach (var item in stars)
  7. 7 {
  8. 8 if (isExist("Name", item[0].ToString()))
  9. 9 {
  10. 10 Console.WriteLine(item[0] + "的数据已存在!");
  11. 11 continue;
  12. 12 }
  13. 13 else
  14. 14 {
  15. 15 sqlHelper.ExecuteNonQuery(commandStr, item);
  16. 16 Console.WriteLine(item[0] + "的数据已保存!");
  17. 17 Console.ReadKey();
  18. 18 }
  19. 19 }
  20. 20 sqlHelper.CloseDbConn();
  21. 21 Console.ReadKey();
  22. 22
  23. 23 }

效果如下:


五、查询数据

SQLite 的 SELECT 语句用于从 SQLite 数据库表中获取数据,以结果表的形式返回数据。这些结果表也被称为结果集。

一个简单的例子:查询一个球星所在的球队。

输入球星的名字,输出球队。

  1. 1 private static void Team(string name)
  2. 2 {
  3. 3 CSQLiteHelper sqliteHelper = new CSQLiteHelper(dbPath);
  4. 4 sqliteHelper.OpenDbConn();
  5. 5 string commandText = @"select * from Stars where Name ='" + name+"'";
  6. 6 DataTable dt = sqliteHelper.Query(commandText).Tables[0];
  7. 7 if (dt.Rows.Count == 0)
  8. 8 {
  9. 9 Console.WriteLine("查无此人!");
  10. 10 Console.ReadLine();
  11. 11 sqliteHelper.CloseDbConn();
  12. 12 return;
  13. 13 }
  14. 14 string team = dt.Rows[0]["Team"].ToString();
  15. 15 sqliteHelper.CloseDbConn();
  16. 16 Console.WriteLine(name + "--" + team);
  17. 17 Console.ReadKey();
  18. 18 }
  1. 1 static void Main(string[] args)
  2. 2 {
  3. 3 Console.WriteLine("请输入一个Star:");
  4. 4 string name = Console.ReadLine();
  5. 5 Team(name);
  6. 6 }

效果如下


六、删除数据

SQLite 的 DELETE 语句用于删除表中已有的记录。可以使用带有 WHERE 子句的 DELETE 查询来删除选定行,否则所有的记录都会被删除。

  1. 1 private static void Delete(string name)
  2. 2 {
  3. 3 CSQLiteHelper sqliteHelper = new CSQLiteHelper(dbPath);
  4. 4 sqliteHelper.OpenDbConn();
  5. 5 string commandtext = "delete from Stars where Name = '" + name + "'";
  6. 6 sqliteHelper.ExecuteNonQuery(commandtext);
  7. 7 sqliteHelper.CloseDbConn();
  8. 8 Console.WriteLine(name + "被删除!");
  9. 9 }

注意:delete语句与select语句不同,delete后直接跟from,不能写成:

  1. "delete * from Stars where [condition];

调用一下

  1. Console.WriteLine("删除球星:");
  2. string starName = Console.ReadLine();
  3. Delete(starName);

删除前:

删除后:

 七、运算符

运算符是一个保留字或字符,主要用于 SQLite 语句的 WHERE 子句中执行操作,如比较和算术运算。

运算符用于指定 SQLite 语句中的条件,并在语句中连接多个条件。

  1. 可以直接在SQLite语句中加入运算符,= - * / % > < = >= <= 等等

参考  SQLite运算符|菜鸟教程

例:

下面代码是首先插入一些NBA球员的信息,然后筛选出球衣号码大于10的球员:

  1. 1 using System;
  2. 2 using System.Collections.Generic;
  3. 3 using System.Data.SQLite;
  4. 4 using System.Data;
  5. 5 using System.IO;
  6. 6 using System.Data.Common;
  7. 7 using System.Diagnostics;
  8. 8
  9. 9
  10. 10 namespace CSharp_SQLite
  11. 11 {
  12. 12 class Program
  13. 13 {
  14. 14
  15. 15 static void Main(string[] args)
  16. 16 {
  17. 17 string dbPath = "NBAStars.nba";
  18. 18 Stopwatch timer = new Stopwatch();
  19. 19 timer.Start();
  20. 20 CSQLiteHelper sqlhelper = new CSQLiteHelper(dbPath);
  21. 21 sqlhelper.OpenDbConn();
  22. 22 sqlhelper.BeginTransaction();
  23. 23 sqlhelper.ExecuteNonQuery("delete from Stars");
  24. 24 #region 球员信息
  25. 25 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Michael Jordan','Bulls','23')");
  26. 26 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('James Harden','Rockets','13')");
  27. 27 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Lebron James','Cavaliers','23')");
  28. 28 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Tracy Mcgrady','Rockets','1')");
  29. 29 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Yao Ming','Rockets','11')");
  30. 30 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Kevin Garnett','Timberwolves','21')");
  31. 31 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Tim Duncan','Supers','21')");
  32. 32 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Vince Carter','Nets','15')");
  33. 33 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Michael Carter Williams','76ers','10')");
  34. 34 #endregion
  35. 35 sqlhelper.Commit();
  36. 36 sqlhelper.CloseDbConn();
  37. 37 timer.Stop();
  38. 38 Console.WriteLine("初始化数据库表单用时:" + timer.Elapsed);
  39. 39
  40. 40
  41. 41 CSQLiteHelper sqlHelper = new CSQLiteHelper(dbPath);
  42. 42 sqlHelper.OpenDbConn();
  43. 43 sqlHelper.BeginTransaction();
  44. 44 DataTable dt = sqlHelper.Query("select Name, Number from Stars where Number > 10").Tables[0];
  45. 45 sqlHelper.Commit();
  46. 46 sqlHelper.CloseDbConn();
  47. 47 Console.WriteLine("球衣号码大于10的球员有:");
  48. 48 for (int i = 0; i < dt.Rows.Count; i++)
  49. 49 {
  50. 50 Console.WriteLine(dt.Rows[i]["Name"] + "\t" + dt.Rows[i]["Number"]);
  51. 51 }
  52. 52 Console.ReadLine();
  53. 53 }
  54. 54
  55. 55 }
  56. 56
  57. 57 }

结果如下:

若想输出这些球员的球衣号码,则应该在select语句修改为

DataTable dt = sqlHelper.Query("select Name, Number from Stars where Number > 10").Tables[0];

将输出修改为

Console.WriteLine(dt.Rows[i]["Name"] + "\t" + dt.Rows[i]["Number"]);

结果如下:

  1. 注:select语句中尽量不要使用select * from,那样会影响效率。

八、like语句

SQLite 的 LIKE 运算符是用来匹配通配符指定模式的文本值。如果搜索表达式与模式表达式匹配,LIKE 运算符将返回真(true),也就是 1。这里有两个通配符与 LIKE 运算符一起使用:

  • 百分号 %
  • 下划线 _

百分号(%)代表零个、一个或多个数字或字符。下划线(_)代表一个单一的数字或字符。这些符号可以被组合使用。

语法

% 和 _ 的基本语法如下:

  1. SELECT column_list
  2. FROM table_name
  3. WHERE column LIKE 'XXXX%'
  4.  
  5. or
  6.  
  7. SELECT column_list
  8. FROM table_name
  9. WHERE column LIKE '%XXXX%'
  10.  
  11. or
  12.  
  13. SELECT column_list
  14. FROM table_name
  15. WHERE column LIKE 'XXXX_'
  16.  
  17. or
  18.  
  19. SELECT column_list
  20. FROM table_name
  21. WHERE column LIKE '_XXXX'
  22.  
  23. or
  24.  
  25. SELECT column_list
  26. FROM table_name
  27. WHERE column LIKE '_XXXX_'

您可以使用 AND 或 OR 运算符来结合 N 个数量的条件。在这里,XXXX 可以是任何数字或字符串值。

我们在球员中筛选出名字中包含James的球员

  1. 1 using System;
  2. 2 using System.Collections.Generic;
  3. 3 using System.Data.SQLite;
  4. 4 using System.Data;
  5. 5 using System.IO;
  6. 6 using System.Data.Common;
  7. 7 using System.Diagnostics;
  8. 8
  9. 9
  10. 10 namespace CSharp_SQLite
  11. 11 {
  12. 12 class Program
  13. 13 {
  14. 14
  15. 15 static void Main(string[] args)
  16. 16 {
  17. 17 string dbPath = "NBAStars.nba";
  18. 18 Stopwatch timer = new Stopwatch();
  19. 19 timer.Start();
  20. 20 CSQLiteHelper sqlhelper = new CSQLiteHelper(dbPath);
  21. 21 sqlhelper.OpenDbConn();
  22. 22 sqlhelper.BeginTransaction();
  23. 23 sqlhelper.ExecuteNonQuery("delete from Stars");
  24. 24 #region 球员信息
  25. 25 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Michael Jordan','Bulls','23')");
  26. 26 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('James Harden','Rockets','13')");
  27. 27 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Lebron James','Cavaliers','23')");
  28. 28 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Tracy Mcgrady','Rockets','1')");
  29. 29 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Yao Ming','Rockets','11')");
  30. 30 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Kevin Garnett','Timberwolves','21')");
  31. 31 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Tim Duncan','Supers','21')");
  32. 32 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Vince Carter','Nets','15')");
  33. 33 sqlhelper.ExecuteNonQuery("insert into Stars (Name,Team,Number) values('Michael Carter Williams','76ers','10')");
  34. 34 #endregion
  35. 35 sqlhelper.Commit();
  36. 36 sqlhelper.CloseDbConn();
  37. 37 timer.Stop();
  38. 38 Console.WriteLine("初始化数据库表单用时:" + timer.Elapsed);
  39. 39
  40. 40
  41. 41 CSQLiteHelper sqlHelper = new CSQLiteHelper(dbPath);
  42. 42 sqlHelper.OpenDbConn();
  43. 43 sqlHelper.BeginTransaction();
  44. 44 DataTable dt = sqlHelper.Query("select Name, Number from Stars where Name like '%James%'").Tables[0];
  45. 45 sqlHelper.Commit();
  46. 46 sqlHelper.CloseDbConn();
  47. 47 Console.WriteLine("名字中包含James的球员有:");
  48. 48 for (int i = 0; i < dt.Rows.Count; i++)
  49. 49 {
  50. 50 Console.WriteLine(dt.Rows[i]["Name"] + "\t" + dt.Rows[i]["Number"]);
  51. 51 }
  52. 52 Console.ReadLine();
  53. 53 }
  54. 54
  55. 55 }
  56. 56
  57. 57 }

其中第44行代码 DataTable dt = sqlHelper.Query("select Name, Number from Stars where Name like '%James%'").Tables[0];

%James%表示前面和后面包含零个、一个或多个数字或字符,也就是包含名字内James

运行结果如下

前言:

这一段来自SQLite官网

SQLite is an in-process library that implements a self-containedserverlesszero-configurationtransactionalSQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the world with more applications than we can count, including several high-profile projects.

SQLite 是一个软件库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。SQLite 源代码不受版权限制。SQLite 是在世界上最广泛部署的 SQL 数据库引擎。SQLite是世界上应用最广泛的数据库,拥有着不计其数的应用,包括备受瞩目的项目

手把手教你使用C#操作SQLite数据库,新建数据库,创建表,插入,查询,删除,运算符,like的更多相关文章

  1. sqlalchemy操作----建表 插入 查询 删除

    ... #!_*_coding:utf-8_*_ #__author__:"Alex huang" import sqlalchemy from sqlalchemy import ...

  2. Hibernate连接mysql数据库并自动创建表

    天才第一步,雀氏纸尿裤,Hibernate第一步,连接数据库. Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个 ...

  3. 创建ACCESS数据库,并且创建表和数据。重点:关闭ACCESS数据库引用

    /// <summary> /// 创建ACCESS数据库,并且创建表和数据 /// </summary> /// <param name="dictTable ...

  4. shell脚本操作mysql数据库—创建数据库,在该数据库中创建表(插入,查询,更新,删除操作也可以做)

    #!/bin/bash HOSTNAME="192.168.1.224"                                           #数据库Server信 ...

  5. Oracle数据库体系结构及创建表结构

    Oracle服务器主要由实例.数据库.程序全局区和前台进程组成,其中实例就是用来提供管理数据库的功能:数据库由数据库文件组成,用来存储系统数据:实例可以进一步划分为系统全局区(SGA)和后台进程(PM ...

  6. SQLite使用教程6 创建表

    http://www.runoob.com/sqlite/sqlite-create-table.html SQLite 创建表 SQLite 的 CREATE TABLE 语句用于在任何给定的数据库 ...

  7. Laravel5.5 数据库迁移:创建表与修改表

    数据库迁移是数据库的版本管理,要使用数据库迁移,需要在.env文件中连接好数据库(不多说).laravel本身已经存在user表和password_resets表的迁移了,因此,执行 php arti ...

  8. MySQL数据库 存储引擎,创建表完整的语法,字段类型,约束条件

    1.存储引擎 - 存储引擎是用于根据不同的机制处理不同的数据. - 查看mysql中所有引擎: - show engines; - myisam: 5.5以前老的版本使用的存储引擎 - blackho ...

  9. mongodb操作之使用javaScript实现多表关联查询

    一.数据控制 mongodb操作数据量控制,千万控制好,不要因为操作的数据量过多而导致失败. 演示一下发生此类错误的错误提示:

随机推荐

  1. 200行代码实现RPC框架

    之前因为项目需要,基于zookeeper和thrift协议实现了一个简单易用的RPC框架,核心代码不超过200行. zookeeper主要作用是服务发现,thrift协议作为通信传输协议, 基于com ...

  2. 第7月第27天 c++11 boost

    1. #include <boost/asio.hpp> #include <cstdlib> #include <memory> namespace asio = ...

  3. [MySQL 5.6] GTID实现、运维变化及存在的bug

    [MySQL 5.6] GTID实现.运维变化及存在的bug http://www.tuicool.com/articles/NjqQju 由于之前没太多深入关注gtid,这里给自己补补课,本文是我看 ...

  4. 转载 为什么print在Python 3中变成了函数?

    转载自编程派http://codingpy.com/article/why-print-became-a-function-in-python-3/ 原作者:Brett Cannon 原文链接:htt ...

  5. RabbitMq Queue一些方法及参数

    方法: 1.QueueDeclare 声明队列 public static QueueDeclareOk QueueDeclare(String queue, Boolean durable, Boo ...

  6. 【干货】Linux内存数据的获取与转存 直捣密码

    知识源:Unit 2: Linux/Unix Acquisition 2.1 Linux/Unix Acquistion Memory Acquisition 中的实验demo部分  小白注意,这是网 ...

  7. PHP中VC6、VC9、TS、NTS版本区别与用法

    1. VC6与VC9的区别: VC6 版本是使用 Visual Studio 6 编译器编译的,如果你的 PHP 是用 Apache 来架设的,那你就选择 VC6 版本.  VC9 版本是使用 Vis ...

  8. springcloud使用Hystrix实现微服务的容错处理

    使用Hystrix实现微服务的容错处理 容错机制 如果服务提供者相应非常缓慢,那么消费者对提供者的请求就会被强制等待,知道提供者相应超时.在高负载场景下,如果不作任何处理,此类问题可能会导致服务消费者 ...

  9. FileInputStram入门

    1.read() 读取一个字节 @Test public void test1() throws Exception{  //1.指定文件读取路径  String filePath = "E ...

  10. 无root或sudo权限,安装mysql

    这其实才是真正的linux,恰当使用权限. 网上找到的中文博客,基本上就那么几篇原创,都要编译源码.但89服务器性能太差编译一次大约半小时无法忍受,在本机上创建了standard用户去尝试几篇博客所言 ...