摘要:参考: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
阅读全文
摘要:选中某个数据库后, 执行查询 SHOW VARIABLES LIKE "general_log%" 如果general_log值不是ON, 执行SET GLOBAL general_log = 'ON'; 路径类似可以修改. 如果只想记录慢查询: # 开启慢查询日志SET GLOBAL slow_q
阅读全文
摘要:0.CentOS 8下yum安装不了mysql了, 可以使用2步的方法安装, CentOS 8推荐使用MariaDB与mysql-community名字不同, 使用命令还是mysql centos 8 安装 MariaDB首先,更新你的包管理器的仓库索引:sudo yum update安装Maria
阅读全文
摘要:安装redis //更新包索引sudo apt-update //安装redis服务sudo apt-get install redis-server //查看redis运行状态sudo systemctl status redis-server或sudo service redis status
阅读全文
摘要: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, 就补
阅读全文
摘要:mongodb修改数据, 条件是: nickname以StressRobot开头, 对应每行字段的gold设置为5000 db.user.updateMany( { "nickname": { $regex: "^StressRobot" } }, { "$set": { "gold": 5000
阅读全文
摘要:db.user.aggregatet([ { $sort:{score: -1} }, { $group:{ _id:null, users:${ $push:{nickname:"$nickname", score: "$score"} }, count: {$sum:1}, } }, { $pr
阅读全文
摘要: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
阅读全文
摘要:利用row_number over(partition by ..) times =1 来去重 row_number over(order by ..) between and 来分页
阅读全文
摘要:C#读取一些C++创建的sqlite数据库时乱码, C++保存DB是用GB2312编码的, C#调用的官方的system.data.sqlite是用的UTF-8编码的, 在读取时会乱码, 用一个GB2312编码的system.data.sqlite就行了.可以下载sqlite源码修改重编译dll修改...
阅读全文
摘要:use mastergoalter database dbname set recovery simple with no_waitgoalter database dbname set recovery simplegouse dbnamedbcc shrinkfile(N'DNName_log'...
阅读全文
摘要:数据库表A有十万条记录,查询速度本来还可以,但导入一千条数据后,问题出现了。当选择的数据在原十万条记录之间时,速度还是挺快的;但当选择的数据在这一千条数据之间时,速度变得奇慢。凭经验,这是索引碎片问题。检查索引碎片DBCC SHOWCONTIG(表),得到如下结果:DBCC SHOWCONTIG 正在扫描 'A' 表...表: 'A'(884198200);索引 ID: 1,数据库 ID: 13已执行 TABLE 级别的扫描。- 扫描页数.....................................: 3127- 扫描扩展盘区数...........
阅读全文
摘要:用 游标(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.
阅读全文
摘要: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定义游标, 打开游标, 关闭游标, 清除游标
阅读全文
摘要:说明:列出数据库里所有的表名selectnamefromsysobjectswheretype='U'说明:列出表里的所有的列selectnamefromsyscolumnswhereid=object_id('TableName')
阅读全文
摘要:BACKUP LOG databasename WITH NO_LOG;DBCC SHRINKFILE(log_file_name);删除sqlserver2008日记文件
阅读全文
摘要: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..
阅读全文
摘要:alter table mytable drop column mycol1, mycol2
阅读全文
摘要:select name from syscolumns where id = object_id(N'mytable')
阅读全文
摘要:原来编号是分段的, 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)
阅读全文