代码改变世界

随笔分类 -  Scripts

【MySQL】MySQL中如何定位DDL被阻塞的问题

2022-06-24 22:47 by abce, 156 阅读, 收藏, 编辑
摘要: 1.查看DDL阻塞 查看DDL操作对应的状态 show processlist; 2.(MySQL5.6)定位哪些会话阻塞了DDL操作 select * from information_schema.innodb_trx; information_schema.innodb_trx.trx_mys 阅读全文

【MySQL】MySQL自动化安装脚本

2022-06-19 14:22 by abce, 347 阅读, 收藏, 编辑
摘要: RHEL7自动安装mysql5.7 #!/bin/bash # #首先将压缩文件和配置文件(mysql57.cnf)放到/software目录 #软件目录:/usr/local/mysql #数据目录:/data/mysql_data #mysql-files目录:/data/mysql-files 阅读全文

【MonoDB】MongoDB自动化安装脚本

2022-06-19 14:08 by abce, 135 阅读, 收藏, 编辑
摘要: #!/bin/bash soft_dir="/tmp" soft_name="mongodb-linux-x86_64-rhel70-5.0.11.tgz" #安装依赖 yum install libcurl openssl xz-libs wget -y #下载安装包 cd $soft_dir [ 阅读全文

【PostgreSQL】使用查询语句分析锁队列

2022-06-11 20:57 by abce, 114 阅读, 收藏, 编辑
摘要: \timing on set statement_timeout to '100ms'; with recursive activity as ( select pg_blocking_pids(pid) blocked_by, *, age(clock_timestamp(), xact_star 阅读全文

【SqlServer】统计索引使用情况解决DB的CPU高和IO高的问题

2022-06-03 09:30 by abce, 515 阅读, 收藏, 编辑
摘要: 转载地址:https://segmentfault.com/a/1190000018022330 查看表的索引情况: use [数据库名] sp_helpindex 表名; 查看索引使用情况: user_seeks和user_scans字段都为0的,考虑是否为垃圾索引 另外last_user_see 阅读全文

【SqlServer】使用IO比较高的语句

2022-06-02 20:10 by abce, 159 阅读, 收藏, 编辑
摘要: select top 100 (total_logical_reads / execution_count) as avg_logical_reads, (total_logical_writes / execution_count) as avg_logical_writes, (total_ph 阅读全文

创建数据库和普通用户

2022-06-01 22:05 by abce, 41 阅读, 收藏, 编辑
摘要: 创建数据库和普通用户 create database test; create user abce with password 'xxxxxx'; grant all on database test to abce; alter user abce with valid until 'infini 阅读全文

【Orace】job相关脚本

2022-05-30 21:19 by abce, 63 阅读, 收藏, 编辑
摘要: # 查看数据库中的所有job# scheduled_dbms_jobs.sql set linesize 250 col log_user for a10 col job for 9999999 head 'Job' col broken for a1 head 'B' col failures f 阅读全文

oracle查看sql中的绑定变量

2022-05-24 15:56 by abce, 442 阅读, 收藏, 编辑
摘要: alter session set nls_date_format = 'yyyy-mm-dd,hh24:mi:ss'; set linesize 300 col sql_Id format a25 col name format a25 col datatype_string format a20 阅读全文

查看引起"TX - row lock contention"的语句

2022-03-23 16:14 by abce, 76 阅读, 收藏, 编辑
摘要: #当前会话中查看引起行锁竞争的语句 select sw.event, sw.sid, sw.p1, sw.p2, sw.p3, s.ROW_WAIT_OBJ#, s.ROW_WAIT_FILE#, s.ROW_WAIT_BLOCK#, s.ROW_WAIT_ROW#, o.OWNER, o.OBJE 阅读全文

【SQLServer】sqlserver使用cpu比较高的语句

2022-03-23 16:11 by abce, 76 阅读, 收藏, 编辑
摘要: SELECT TOP 10 s.session_id, r.status, r.cpu_time, r.logical_reads, r.reads, r.writes, r.total_elapsed_time / (1000 * 60) 'Elaps M', SUBSTRING(st.TEXT, 阅读全文

How to Script Login and User Permissions in SQL Server

2022-03-10 20:12 by abce, 158 阅读, 收藏, 编辑
摘要: http://udayarumilli.com/script-login-user-permissions-sql-server/ Migrating login and user permissions to a new instance is one of the most common tas 阅读全文

导出sqlserver数据库中的登录用户和密码信息

2022-03-10 15:02 by abce, 1249 阅读, 收藏, 编辑
摘要: https://docs.microsoft.com/en-US/troubleshoot/sql/security/transfer-logins-passwords-between-instances 创建存储过程,生成需要的脚本,传输logins和密码: 在[数据库]-->[系统数据库]--> 阅读全文

使用mysqlbinlog远程备份binlog

2022-03-04 20:17 by abce, 201 阅读, 收藏, 编辑
摘要: #!/bin/sh MBL=/usr/local/mysql/bin/mysqlbinlog MYSQLHOST=192.168.56.1 MYSQLPORT=3306 MYSQLUSER=replication_user MYSQLPASS=replication_pass BACKUPDIR=/ 阅读全文

从mysqldump备份中恢复一个表

2022-02-27 20:05 by abce, 118 阅读, 收藏, 编辑
摘要: 假设要恢复的表是 abce.abce #提取abce库的所有数据 sed -n '/^-- Current Database: `abce`/,/^-- Current Database:/p' backup.sql > backup_abce.sql #从库备份文件中提取建表语句 sed -e'/ 阅读全文
点击右上角即可分享
微信分享提示