随笔分类 - 数据库
摘要:SELECT 表名=case when a.colorder=1 then d.name else '' end, 表说明=case when a.colorder=1 then isnull(f.value,'') else '' end, 序号=a.colorder, 字段名=a.name, 主
阅读全文
摘要:1.查询优化,应尽量避免全表扫描,首先考虑在 where 及 order by 涉及的列上建立索引。 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: select id from t where num is null 可以在num上
阅读全文
摘要:--声明游标 declare test_Cursor CURSOR FOR SELECT id,name FROM table_name --打开游标 OPEN test_Cursor --声明游标提取变量所要存放的变量 declare @id int,@name varchar(20) --定位游
阅读全文
摘要:OPEN SYMMETRIC KEY keyName DECRYPTION BY CERTIFICATE certName; declare @as nvarchar(12)='122' select CONVERT(NVARCHAR(30), DECRYPTBYKEY(ENCRYPTBYKEY(K
阅读全文
摘要:查看索引 exec sp_helpindex tablename 删除索引 drop index index_name on table_name 创建索引 1 --唯一 聚集索引 2 CREATE UNIQUE CLUSTERED INDEX indexName ON tableName(colu
阅读全文
摘要:一、下载 windows:https://github.com/tporadowski/redis/releases redis官网上都是Linux版本,不过文档可以学习一下 Linux:https://redis.io/download 二、安装/启动 Windows:压缩包下载后解压,用dos命
阅读全文
摘要:获取服务器时间 select getdate()select FORMAT(CAST( '2024-01-02 12:2:1' as datetime),'MM-dd') 01-02--yyyy:四位数的年份。--MM:两位数的月份,带前导零 (注意和分钟区分,分钟是小写的mm)--MMM:缩写的月
阅读全文
摘要:CREATE TABLE #tblOrder( code bigint NOT NULL, name varchar(4) NOT NULL ) DECLARE @TempTable TABLE ( value0 varchar(100), update_date datetime ) 临时表 表变
阅读全文
摘要:MERGE INTO table_name t1 USING (SELECT * FROM table_name) t2 ON t1.column= t2.columnWHEN MATCHED THEN UPDATE SET t1.col1 = t2.col1, t1.col2 = t2.col2
阅读全文
摘要:DECLARE @idoc int DECLARE @doc varchar(1000) set @doc=N'<ROOT> <Customer CustomerID="VINET" ContactName="Paul Henriot"> <Order OrderID="10248" Custome
阅读全文