悉野小楼

导航

随笔分类 -  DB

1 2 下一页

T-Sql使用
Amazon Linux 2023上安装MariaDB
摘要:参考:https://zhuanlan.zhihu.com/p/649682551 1. 先更新 sudo dnf update 2.在Amazon Linux 2023上安装MariaDB 10.05 sudo dnf install mariadb105-server 3.启动mariadb s 阅读全文

posted @ 2024-11-05 14:35 悉野 阅读(37) 评论(0) 推荐(0) 编辑

mysql记录所有sql文句
摘要:选中某个数据库后, 执行查询 SHOW VARIABLES LIKE "general_log%" 如果general_log值不是ON, 执行SET GLOBAL general_log = 'ON'; 路径类似可以修改. 如果只想记录慢查询: # 开启慢查询日志SET GLOBAL slow_q 阅读全文

posted @ 2024-08-14 12:11 悉野 阅读(2) 评论(0) 推荐(0) 编辑

centos 7 安装mysql5.7
摘要:0.CentOS 8下yum安装不了mysql了, 可以使用2步的方法安装, CentOS 8推荐使用MariaDB与mysql-community名字不同, 使用命令还是mysql centos 8 安装 MariaDB首先,更新你的包管理器的仓库索引:sudo yum update安装Maria 阅读全文

posted @ 2024-05-27 17:44 悉野 阅读(104) 评论(0) 推荐(0) 编辑

ubuntu redis导入dump.rdb
摘要:安装redis //更新包索引sudo apt-update //安装redis服务sudo apt-get install redis-server //查看redis运行状态sudo systemctl status redis-server或sudo service redis status 阅读全文

posted @ 2024-05-21 07:24 悉野 阅读(88) 评论(0) 推荐(0) 编辑

mysql允许其它机器连接
摘要:1.修改MySQL的配置文件(windows是my.ini, linux是 my.cn.cnf或my.cnf),如果有bind-address这一行,值改为0.0.0.0,这样可以允许任意IP地址连接到MySQL服务器。bind-address = 0.0.0.0没有bind-address, 就补 阅读全文

posted @ 2024-05-20 22:13 悉野 阅读(814) 评论(0) 推荐(0) 编辑

mongodb修改数据
摘要:mongodb修改数据, 条件是: nickname以StressRobot开头, 对应每行字段的gold设置为5000 db.user.updateMany( { "nickname": { $regex: "^StressRobot" } }, { "$set": { "gold": 5000 阅读全文

posted @ 2024-04-28 14:11 悉野 阅读(27) 评论(0) 推荐(0) 编辑

mongodb查询玩家排名
摘要:db.user.aggregatet([ { $sort:{score: -1} }, { $group:{ _id:null, users:${ $push:{nickname:"$nickname", score: "$score"} }, count: {$sum:1}, } }, { $pr 阅读全文

posted @ 2024-01-03 14:22 悉野 阅读(81) 评论(0) 推荐(0) 编辑

MySql获取一个最小的空ID
摘要:id列中的已有的数据1,2,7,8,9, 业务需要从id列中找出一个最小的没占用的, 上面应该查出的结果是3. 例: select @rowNum:=@rowNum + 1 AS rn,a.id FROM tabName a,(select @rowNum:=0) b order by id asc 阅读全文

posted @ 2021-03-17 17:03 悉野 阅读(327) 评论(0) 推荐(0) 编辑

t-sql查询去重分页
摘要:利用row_number over(partition by ..) times =1 来去重 row_number over(order by ..) between and 来分页 阅读全文

posted @ 2016-06-28 11:09 悉野 阅读(370) 评论(0) 推荐(0) 编辑

sqlite读取中文乱码(C#)
摘要:C#读取一些C++创建的sqlite数据库时乱码, C++保存DB是用GB2312编码的, C#调用的官方的system.data.sqlite是用的UTF-8编码的, 在读取时会乱码, 用一个GB2312编码的system.data.sqlite就行了.可以下载sqlite源码修改重编译dll修改... 阅读全文

posted @ 2015-04-28 13:26 悉野 阅读(3396) 评论(3) 推荐(0) 编辑

删除sqlserver2008日记文件
摘要:use mastergoalter database dbname set recovery simple with no_waitgoalter database dbname set recovery simplegouse dbnamedbcc shrinkfile(N'DNName_log'... 阅读全文

posted @ 2014-05-30 10:27 悉野 阅读(217) 评论(0) 推荐(0) 编辑

[转]整理索引碎片,提升SQL Server速度
摘要:数据库表A有十万条记录,查询速度本来还可以,但导入一千条数据后,问题出现了。当选择的数据在原十万条记录之间时,速度还是挺快的;但当选择的数据在这一千条数据之间时,速度变得奇慢。凭经验,这是索引碎片问题。检查索引碎片DBCC SHOWCONTIG(表),得到如下结果:DBCC SHOWCONTIG 正在扫描 'A' 表...表: 'A'(884198200);索引 ID: 1,数据库 ID: 13已执行 TABLE 级别的扫描。- 扫描页数.....................................: 3127- 扫描扩展盘区数........... 阅读全文

posted @ 2013-12-17 09:14 悉野 阅读(181) 评论(0) 推荐(0) 编辑

[转]sql利用游标循环,遍历表循环结果集
摘要:用 游标(Cursor) + While循环 的方法, 对Customers表中的CompanyName列进行遍历declare @customer nvarchar(50)declare pcurr cursor forselect distinct companyname from customersopen pcurrfetch next from pcurr into @customerwhile (@@fetch_status = 0)begin print (@customer) fetch next from pcurr into @customerendclose pcurr. 阅读全文

posted @ 2013-06-20 16:35 悉野 阅读(268) 评论(1) 推荐(0) 编辑

SqlServer游标
摘要:declare @id intdeclare my_cursor cursorfor select id from mytableopen my_cursorfetch next from my_cursor into @idwhile(@@fetch_status=0)beginprint @idfetch next from my_cursor into @idendclose my_cursordeallocate my_cursor定义游标, 打开游标, 关闭游标, 清除游标 阅读全文

posted @ 2012-12-20 12:08 悉野 阅读(157) 评论(0) 推荐(0) 编辑

SqlServer查询所有表名 查询表的所有列名
摘要:说明:列出数据库里所有的表名selectnamefromsysobjectswheretype='U'说明:列出表里的所有的列selectnamefromsyscolumnswhereid=object_id('TableName') 阅读全文

posted @ 2012-12-17 11:29 悉野 阅读(734) 评论(0) 推荐(0) 编辑

删除sqlserver2005日记文件
摘要:BACKUP LOG databasename WITH NO_LOG;DBCC SHRINKFILE(log_file_name);删除sqlserver2008日记文件 阅读全文

posted @ 2012-10-19 17:10 悉野 阅读(133) 评论(0) 推荐(0) 编辑

Sql 更新一列为行号
摘要:update employeeset emp_id=t1.rowIdfrom( --select * from --( select Emp_UserName,ROW_NUMBER() over(Order by emp_username) as rowId from employee ) as t1 where t1.Emp_UserName=employee.Emp_UserName--) as thttp://social.msdn.microsoft.com/Forums/zh-CN/sqlserverzhchs/thread/6160088e-524f-412c-93be-e76.. 阅读全文

posted @ 2012-06-11 22:06 悉野 阅读(3167) 评论(0) 推荐(0) 编辑

Sql 删除表格的列
摘要:alter table mytable drop column mycol1, mycol2 阅读全文

posted @ 2012-06-11 11:06 悉野 阅读(256) 评论(0) 推荐(0) 编辑

T-Sql 查询表的列
摘要:select name from syscolumns where id = object_id(N'mytable') 阅读全文

posted @ 2012-06-11 11:05 悉野 阅读(143) 评论(0) 推荐(0) 编辑

Sqlserver数据表中, 从不连续数字编号中得到最小空缺值
摘要:原来编号是分段的, 1-1000表示一个类别, 1000-2000表示一个类别. 现在编号自动生成不要类别, 要找原来数据中最小的数据编号.本想是用个2分递归来查, 但效率太慢了. 想到了个方法用行号.select id, row_number() over (order by id) as rownum from items上面可以查询出id与行号对应的表, 再查看rownum与id不同就是空的id号了.完整为:select top 1 rownum from (select id, row_number() over (order by id) as rownum from items) 阅读全文

posted @ 2012-04-13 10:45 悉野 阅读(1834) 评论(1) 推荐(0) 编辑

1 2 下一页
点击右上角即可分享
微信分享提示