随笔分类 -  数据库-关系数据库

Oracle,Sqlserver,MySql,Sqlite等
摘要:1 using System; 2 using System.Linq; 3 using System.Text; 4 using System.Text.RegularExpressions; 5 using System.Web; 6 7 namespace HOST_CONTROL_CENTE 阅读全文
posted @ 2021-12-13 14:23 ꧁执笔小白꧂ 阅读(396) 评论(0) 推荐(0) 编辑
摘要:MSSQL向有数据的表中插入主键,因“设为主键的列有重复值“引发的报错。 下面是解决方案: -- 1.查询表中重复的值 举例是两个条件SELECT m.* into test1111 FROM dbo.[Ct2] m,( SELECT [cInvCCode],[Datasource] FROM db 阅读全文
posted @ 2021-11-29 23:52 ꧁执笔小白꧂ 阅读(553) 评论(0) 推荐(0) 编辑
摘要:存在就更新,不存在就插入 1 IF NOT EXISTS ( 2 SELECT 3 cInvCCode 4 FROM 5 [{0}].[dbo].InvDefaultValue 6 WHERE 7 cInvCCode = @cInvCCode 8 ) 9 INSERT 10 INTO [{0}].[ 阅读全文
posted @ 2021-11-24 11:39 ꧁执笔小白꧂ 阅读(102) 评论(0) 推荐(0) 编辑
摘要:IF EXISTS(SELECT 1 FROM sys.views WHERE name='View_ProductInStockBill') DROP VIEW View_ProductInStockBill https://www.cnblogs.com/YyuTtian/p/4610953.h 阅读全文
posted @ 2021-11-24 11:35 ꧁执笔小白꧂ 阅读(61) 评论(0) 推荐(0) 编辑
摘要:未整理 一,减少 select * 语句,尽量使用覆盖索引。 二,where与on的执行顺序。 三,inner join、left join。 1.left join 的on 不能写右表的条件 (如rtable.id='11'、 rtable.id in ('1') ) 四,最好不用(!= 、<> 阅读全文
posted @ 2021-11-10 12:01 ꧁执笔小白꧂ 阅读(38) 评论(0) 推荐(0) 编辑
摘要:标题: Microsoft SQL Server Management Studio 还原数据库“UFDATA_002_2021”时失败。 (Microsoft.SqlServer.Management.RelationalEngineTasks) 其他信息: System.Data.SqlClie 阅读全文
posted @ 2021-11-09 10:13 ꧁执笔小白꧂ 阅读(805) 评论(0) 推荐(0) 编辑
摘要:SQL中FROM数据库名.dbo.表名的DBO 相当于用户名,表示以所有者身份使用表 例如: SELECT * FROM [IP].[数据库名].DBO.表名 IP的需要建立链式服务器,同机不需要加IP 阅读全文
posted @ 2021-11-01 09:12 ꧁执笔小白꧂ 阅读(149) 评论(0) 推荐(0) 编辑
摘要:MSSql: Orlace: Mysql: 待写 阅读全文
posted @ 2021-10-28 17:09 ꧁执笔小白꧂ 阅读(288) 评论(0) 推荐(0) 编辑
摘要:1 阅读全文
posted @ 2021-10-27 14:23 ꧁执笔小白꧂ 阅读(26) 评论(0) 推荐(0) 编辑
摘要:Ctrl+Q 阅读全文
posted @ 2021-10-21 15:13 ꧁执笔小白꧂ 阅读(288) 评论(0) 推荐(0) 编辑
摘要:1 /** 2 *┌──────────────────────────────────────────────────────────────┐ 3 *│ 描 述:数据库相关的工具类 4 *│ 作 者:执笔小白-https://www.cnblogs.com/whpepsi/p/3779217.h 阅读全文
posted @ 2021-10-15 09:41 ꧁执笔小白꧂ 阅读(78) 评论(0) 推荐(0) 编辑
摘要:CONVERT(varchar(19),GETDATE(),120) CONVERT(varchar(19),字段名,120) -- YYYY-MM-dd HH:mm:ss 其他见: https://blog.csdn.net/tangdasa/article/details/106547498 阅读全文
posted @ 2021-10-13 11:24 ꧁执笔小白꧂ 阅读(362) 评论(0) 推荐(0) 编辑
摘要:样式一(对于传入参数的场景,防止sql攻击): using CodeReading.Entity; using CodeReading.Entity.Comm; using CodeReading.Entity.History; using System; using System.Collecti 阅读全文
posted @ 2021-10-13 10:54 ꧁执笔小白꧂ 阅读(292) 评论(0) 推荐(0) 编辑
摘要:using System.Data.SqlClient; 1 string idStr="123"; 2 using (SqlConnection conn = new SqlConnection(Appconfig.GetMSSQLStr())) 3 { 4 5 conn.Open(); 6 us 阅读全文
posted @ 2021-10-12 10:57 ꧁执笔小白꧂ 阅读(240) 评论(0) 推荐(0) 编辑
摘要:方式一: delete from table where id in (select user_id from table2) 方式二: delete a from a,(select id from XXXX where XXX) b where a.id = b.id 阅读全文
posted @ 2021-10-12 09:45 ꧁执笔小白꧂ 阅读(1404) 评论(0) 推荐(0) 编辑
摘要:select database_id,name,physical_name AS CurrentLocation,state_desc,size from sys.master_files where database_id=db_id(N'数据库名'); https://blog.csdn.net 阅读全文
posted @ 2021-10-04 17:44 ꧁执笔小白꧂ 阅读(305) 评论(0) 推荐(0) 编辑
摘要:AND Name like '%中文%' 加N,改为: AND Name like N'%中文%' 阅读全文
posted @ 2021-09-16 15:23 ꧁执笔小白꧂ 阅读(104) 评论(0) 推荐(0) 编辑
摘要:using Dapper; using System.Collections.Generic; using System.Data; using System.Text; namespace DBDapper { /// <summary> /// 分页帮助类 /// </summary> publ 阅读全文
posted @ 2021-07-09 17:10 ꧁执笔小白꧂ 阅读(334) 评论(0) 推荐(0) 编辑
摘要:开始用的 int count = conn.Query<int>(sqlStr, param).FirstOrDefault(); // return count > 0 ? true : false; 报错,所以我用的是 using System.Linq;using Dapper;int cou 阅读全文
posted @ 2021-06-17 16:22 ꧁执笔小白꧂ 阅读(218) 评论(0) 推荐(0) 编辑
摘要:ISNULL(字段名,0) "; // int ISNULL(字段名,"空") "; // string 阅读全文
posted @ 2021-06-01 09:46 ꧁执笔小白꧂ 阅读(637) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示